Using Apache Lucene.Net 4.8.0 with .NET Standard 1.5 and Visual Studio 2017

On the Lucene.Net GitHub page (https://github.com/apache/lucenenet), it says that version 4.8.0 (the beta version currently available on GitHub) is compatible with the .Net Standard 1.5 and .Net 4.5.1 frameworks. Fantastic!

I did a git clone https://github.com/apache/lucenenet.git to pull the code. The solution opened right up and compiled in Visual Studio 2017 with no errors under the default framework of .NET 4.5.1 . All is well thus far.

What I really need is to compile Lucene.NET 4.8.0 to work with .NET Core 1.1.x . This is where things kind of went a bit sideways.

When I opened up the properties page for the Lucene.Net project (as well as the many other included projects), they are all referencing the default .NET 4.5.1 . There does not appear to be any option to reference .NET Standard 1.x or .NET Core 1.xy instead of a standard .NET framework version.

I am sure this must be a really simple fix, but I am at a bit of a loss as to how get Lucene.Net working with .Net Standard / .Net Core .

Here are a few quick notes that might be of interest.

  • The latest Dot Net Core SDK is installed on my machine.
  • I installed the NetStandard.Library to all projects using NuGet Package Manager . (The NetStandard.Library appears in the references for all projects with a blue and white icon. The solution still compiles but I am unable to drill down and see the constituent files in the NetStandard.Library as I can with other .NET Standard or .NET Core projects.)
  • I ran dotnet restore just in case that might have been needed to pull the various files needed for the NetStandard.Library .
  • All of the projects in the solution contain [projectname].project.json files. After installing the NetStandard.Library to each project, there is now a dependencies entry in the [projectname].project.json file.

    "dependencies": { "NETStandard.Library": "1.6.1" }

  • I did attempt to update just the framework entry in the Lucene.Net.project.json file to use .NETStandard,Version=1.5 and then recompile only the Lucene.Net project. I ended up with several compile errors so I reverted the entry to its orginal value of net451 .

  • There is no .csproj file for any of the projects. I did not attempt to run dotnet migrate as I was unsure if it was necessary, and I did not want to introduce additional variables.
  • Any help here is much appreciated. Thank you so much!


    The following answer came from Shad Storhaug on the dev@lucenenet.apache.org mailing list.

    Anthony,

    Since NUnit3 Test Adapter does not yet support it on .NET Core, we have not yet upgraded to the new .csproj format that supports Visual Studio 2017. For the time being we have 2 separate solution files.

    Lucene.Net.sln - for .NET Framework 4.5.1 Lucene.Net.Portable.sln - for .NET Standard 1.5

    You can open up Lucene.Net.Portable.sln in Visual Studio 2015, but it is not compatible with VS2017.

    Prerequisites for VS2015:

    1.1 with SDK Preview 2.1 build 3177 - https://github.com/dotnet/core/blob/master/release-notes/download-archive.md Visual Studio 2015 (Community or greater) with Update 3 NUnit3 Test Adapter (if you need to run the tests) - https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter

    To get it to compile on .NET Standard you may need to run dotnet restore with Visual Studio closed, and then open the Lucene.Net.Portable.sln solution in Visual Studio to build. It does not always succeed when VS2015 runs the restore or if VS2015 has the solution open when you run dotnet restore from the CLI.

    Generally speaking, this setup is only required if you want to debug Lucene.Net or help contribute to our efforts. If you just want to build you can build via CLI from the root of the project:

    Build -pv:4.8.0-beta00001

    Which will install the required SDK automatically, build DLLs for both frameworks and package them up as .nupkg files in the releaseNuGetPackages folder. Make sure you have a recent version of Powershell before you run this command (still trying to work out some issues with earlier versions, but I know it works for sure with 5.1.14393.1066). To determine what version of Powershell you have: https://stackoverflow.com/a/1825807/181087

    Or if you just want to reference the NuGet packages, we have a CI feed available at https://www.myget.org/gallery/lucene-net-ci. Pending the results of a release vote, we will have a beta available on NuGet in a couple of days.

    Thanks, Shad Storhaug (NightOwl888)

    链接地址: http://www.djcxy.com/p/29022.html

    上一篇: PowerShell中的Python 2和3

    下一篇: 在.NET Standard 1.5和Visual Studio 2017中使用Apache Lucene.Net 4.8.0