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

Problem to install NMF-Basics 2.0.* #32

Closed Herbie60D closed 6 years ago

Herbie60D commented 6 years ago

Hello. Currently I use the nuget package NMF-Basics 1.0.99 with .NET Framworke 4.6.1 in Visual Studio 2015 Update 3. When I try to update to the newest version or create a test project and try to freshly install version 2.0.111 i get always the following error for all .NET Frameworks from 4.0 to 6.6.1.

Could not install package 'NMF-Expressions 2.0.111'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I had the same problem with all 2.0.* versions. Version 1.0.99 installs without any problem. I've had a look in the package that causes the error NMF-Expressions. From version 2.0 on there is not net45 folder with the libraries anymore. Instead there is a folder netstandard2.0. Is it intended that the Version 2.0 does not work for the normal .NET Framework anymore or do I miss something?

Thnak you for the help!

georghinkel commented 6 years ago

Hi,

yes, from version 2.0, NMF only supports .NET Standard 2.0 in order to avoid cross-compilation and thus simplify the code. However, .NET 4.6.1 with Visual Studio 2015 should be supported (according to https://github.com/dotnet/cli/issues/6739), but you might have to install the .NET Core 2.0 SDK.

If this absolutely does not work, I can restore the old project files and perform a cross-compilation to .NET Standard 2.0 and .NET Framework 4.0/4.5.

Best,

Georg

Herbie60D commented 6 years ago

Hello Georg. Thank you for the fast reply. Simply installing the .NET Core 2.0 SDK did not fixed the problem, but was the first step.

I installed the SDK, but got no other result than before. https://www.microsoft.com/net/download/windows

Then I found the announcement https://github.com/dotnet/announcements/issues/24. It states that at least Nuget 3.6 is needed in Visual Studio 2015 to reference a .Net Standard 2.0 library. https://www.nuget.org/downloads

Now I got another error message:

To reference a library that targets .NET Standard 1.5 or higher, you need to install the .NET Standard Build Support extension for the .NET Framework https://aka.ms/netstandard-build-support-netfx

I installed the .NET Standard Build Support extension from the link above and got a lot of the following errors.

error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Xml.XmlSerializer.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\Facades\System.Xml.XmlSerializer.dll'. Remove one of the duplicate references.

For this I found the open issue https://github.com/dotnet/sdk/issues/1539 As workaround it is suggested to set \<ImplicitlyExpandDesignTimeFacades>false\</ImplicitlyExpandDesignTimeFacades> in first PropertyGroup element of the project file. I did this an now my project and also a newly created test project compiled.

But now I got a warning for each project that uses NMF-Basics 2.0.*

Warning The referenced component 'System.Net.Http' could not be found.

To solve this I found a workaround in the issue https://github.com/dotnet/sdk/issues/1499#issuecomment-322874417. I added the suggested lines to the end of my project file and the warning disappeared. The second solution would be to delete the reference to 'System.Net.Http' from all projects.

Now I get the warning

warning MSB3061: Unable to delete file "[path removed]System.Net.Http.dll". Access to the path '[path removed]\bin\Debug\System.Net.Http.dll' is denied. Visual Studio seems to block the file by itself, wehn I open the project.

This is the current status of my research how to use a .NET Standard 2.0 assembly from a Visual Studio 2015 project. Maybe this helps someone. I hope Microsoft fixes those issues. For now I will stay with NMF-Basics 1.0.99 and will change the version only when needed.

georghinkel commented 6 years ago

Oh, that looks like a lot of mess, indeed. I did not know it was that difficult to use .NET Standard with Visual Studio 2015 (I am using VS 2017 for quite some time now).

georghinkel commented 6 years ago

This should be fixed now as the latest version has support for .NET 4.5 for most runtime libraries

Herbie60D commented 6 years ago

Thank you! This helps us as long as we have not switched to Visual Studio 2017 in our company.