NMFCode / NMF

This repository contains the entire code for the .NET Modeling Framework
BSD 3-Clause "New" or "Revised" License
36 stars 15 forks source link

Support .NET Standard? #53

Closed tjroamer closed 4 years ago

tjroamer commented 4 years ago

I think this framework is really a great work. I see that the project source contains already .NET Standard target. However, it seems that the target platform of this library (version 2.0.148) is only targeting .NET Framework if I get it from NuGet package manager from Visual Studio. We are looking for a platform-neutral modeling framework, i.e. targeting .NET Core. Do you have plan to provide NuGet package for .NET Standard, such that the library can run on both .NET Framework and .NET core? Thanks.

georghinkel commented 4 years ago

Hi, thanks for the appreciation :)

All Projects in NMF have multiple Targets set up: Projects delivered through NuGet target .NET 4.5, .NET 4.6.1 (because Microsoft officially recommends not to use .NET Standard 2.0 with .NET 4.6.1, see footnote 2 in https://docs.microsoft.com/en-us/dotnet/standard/net-standard) and .NET Standard 2.0. So if you were testing with a .NET Framework Project, Visual Studio will likely reference the .NET Framework versions of .NET, not the .NET Standard Version. However, a .NET Core or Xamarin Project will automatically pick up the .NET Standard Version. Indeed, I had a couple of Projects already that were successfully executing NMF using .NET Core under several Kinds of Linuxes.

The test Projects by the way target .NET Framework 4.5, 4.6.1, 4.7.2 and .NET Core.

Best,

Georg

tjroamer commented 4 years ago

Hi thanks for your quick response, but I still have the problem with NMF NuGet packages in .NET Core, the steps to reproduce:

However, the same steps work for .NET Framework project. Please see attached the screenshot, where the NmfSample3 is a .NET Core project, while the NmfSample2 is a .NET Framework project. The package names are slightly different. What did I do wrong?

image

Best regards,

Kai

georghinkel commented 4 years ago

Hi,

sorry for the late reply. Yes, I think that happened to me also a few times. Please check the package reference in the project file. I have no idea why, but sometimes Visual Studio creates a somehow private reference like the following:

<PackageReference Id="NMF-Basics" Version="...">
    <...>
</PackageReference>

If that is the case, simply delete everything that is inside the package reference element. That should force MSBuild to use all contents of the package. NMF-Basics is a NuGet package that contains a tool but declares references to other packages that have dependencies. The reason for that is that if you use the generator, you will also need the framework code. However, there must be some supersmart optimization that tells once in a while that the framework code can be omitted because the tool works without it (which is true, but not for the generated code).

I will reopen the issue, so please report whether this suggestion has helped.

Best,

Georg

tjroamer commented 4 years ago

Hi,

yes, removing the content inside the PackageReference element solved the problem. Thanks a lot for your help.

BTW, I found out that the problem relies on the "IncludeAssets" element, where the value "compile" is missing. The project worked too after I changed the value of this element to "all" or added the value "compile" into the text. I am not sure whether you can consider fixing it in the NuGet package generation.

NuGet Docu

Best regards,

Kai