I have a project that the target framework is .net standard 2.0, we use the System.Runtime.InteropServices.RuntimeInformation.OSDescription in our source code, but this library isn't support .net framwwork 4.6.1.Yesterday, one of our customer report a bug, about this question. his local framework is .net framework 4.6.1.
Can I set the target Framework to make a notice to user during they add the reference from Nuget Package?
And to make user to know if your local framework is 4.6.1, you should not use this version package and will cause bug.
When I set the target frameworks to:
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
<PropertyGroup/>
Then run dotnet build I get the error message:
error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found.
To resolve this, install the SDK or Targeting Pack for this framework version
or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed.
Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies.
Therefore your assembly may not be correctly targeted for the framework you intend.
Then I go to the office website to download .net framework 4.7.1 SDK, but I install fail.
The error message is
A .NET Framework 4.7.1 or higher update has been installed on this computer
So I am confused!
Here is my dotnet --info
It seems I make a joke, I download the .net framework 4.7.1 from .net framework 4.7.1, but I can't install it. However, when I use Visual Studio Installer to install .net framework 4.7.1. It's fine.
And now run dotnet build, It success. More confused am I, Why can't install it from .exe file.
Related
My project uses .net framework 4.8. After upgrading microsoft.net.sdk.functions from version 1.0.24 to 3.0.1, the build on my local machine works fine, but there are some errors on the build on VSO pipeline:
microsoft.net.sdk.functions\3.0.1\build\microsoft.net.sdk.functions.build.targets(41,5):
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '3.0.0' was
not found
microsoft.net.sdk.functions\3.0.1\build\microsoft.net.sdk.functions.build.targets(41,5):
metadata generation failed.
There is no version 3.0.0 for Microsoft.NetCore.App nuget package. Why would the error ask for that version? Also how can I fix the error?
Looking at the package on NuGet, version 3.0.1 is intended for use with .NET Core 3.0 and higher applications, not .NET Framework applications. Version 1.0.38 appears to be the latest version with .NET Framework support (4.6 and higher).
I have a libary that targets multiple frameworks in the project file.
<PropertyGroup>
<TargetFrameworks>netstandard1.1;netstandard2.0;net45</TargetFrameworks>
</PropertyGroup>
However, when running it on macOS I get the following errors because NETFramework 4.5 is not installed on the macOS.
/usr/local/share/dotnet/sdk/3.1.403/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.8 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Users/x.x/Repos/kevbite/CompaniesHouse.NET/src/CompaniesHouse.Tests/CompaniesHouse.Tests.csproj]
/usr/local/share/dotnet/sdk/3.1.403/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.8 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Users/x.x/Repos/kevbite/CompaniesHouse.NET/src/CompaniesHouse.IntegrationTests/CompaniesHouse.IntegrationTests.csproj]
/usr/local/share/dotnet/sdk/3.1.403/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Users/x.x/Repos/kevbite/CompaniesHouse.NET/src/CompaniesHouse/CompaniesHouse.csproj]
How do I only build the projects that are compatible with what is installed on the machine? as I'm not going to be able to get net45 for macOS.
You will not be able to compile something that is targeted for 4.5 with 3.1!
There are breaking changes from 3 to 4 (I didn't check it).
But anyways maybe you're really lucky and it works with just changing it to net31, I doubt it.
You can try intall dotnet 45 via mono:
Is there a way to install .net framework 4.5.2 or higher on Mac OS X?
In the project I am currently working on, there are several projects in the solution. I had to change the target version of a particular project, which is responsible for handling particular APIs of the project, for installing certain Nuget Packages.
Now there are some .dll not found errors coming when I try to run the project.
How can I resolve this issue?
My project is based on .net framework and I am using Visual Studio 2017.
My actual Target version was .NET Framwork 4.5.1.
I had to change it to 4.6.1 since the package I was trying to install IBM.Watson.NaturalLanguageUnderstanding.v1 -Version 4.2.1 package.
Errors are like this:
Metadata file 'location\ProjectName.dll' could not be found.
My actual Target version was .NET Framwork 4.5.1. I had to change it
to 4.6.1 since the package I was trying to install
IBM.Watson.NaturalLanguageUnderstanding.v1 -Version 4.2.1 package.
I recreated the problem by attempting to install the nuget on a new console app targeting .netframework 4.6.1 and it failed
This is where problem lies, IBM Watson NaturalLanguageUnderstanding is compatible with .NETStandard 2.0 Specification which means you would need to target 4.6.1 (*2) ideally, but here is the catch (as explained here MSDN)
2 ways to solve this
Target .NetFramework 4.7.1 as recommended by the MSDN above OR
If you want to use 4.6.1 then you would need to add this to your .CSPROJ file
<PropertyGroup>
.
.
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
To resolve the issues, change the target frameworks of the projects that are dependent on the project for which the target framework was changed. In most cases, there won't be much problem since Microsoft gives backward compatibility. There might be some problems with third-party NuGet packages. Also, some reference errors might come when deployed.
I want to use WebDriverManager in my code when I am trying to install the reference from the Nuget Package Manager I get an error.
I have tried updating and degrading the .Net framework.
Can we use WebDriverManager 2.7.0 with .Net framework 4.5?
Error Message seen is :
Could not install package 'WebDriverManager 2.7.0'. You are trying to install this package into a project that targets '.NETFramework, Version=v4.5', 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 know this post is old but I ran into the same issue today and was able to figure it out. You need to install version 2.2.7 instead. WebDriverMangaer version 2.2.8 and above require .Net Standard 2.0 which is only compatible with .NET Framework 4.6.1 and above.
I created a ASP.NET Core web application. In this solution I also have a .NET Standard 2.0 project.
First I added a reference from .NET Standard project to a dll (.NET framework 4.6.1) manually without any issues and it works fine. I have then created a Nuget package for .NET framework dll, and tried to install this package in .NET Standard project.
I got an error
Package xxx was restored using .net framework, version = 4.6.1. instead of project target framework '.NET standard, version = v2.0'. This package may not be fully compatible with your project.
I am confused, how come i can use a .net framework assembly when referenced manually, and when it is installed via nuget i receive this error.
Further more, when i install this nuget in .NET Core 2.1. project (same solution) i get the same error.
This warning is specific to NuGet. When manually adding a dll, no part in the build checks the target framework of that dll (in theory, most dll files should carry a TargetFrameworkAttribute assembly metadata but it isn't required) and you are responsible for making sure that you are using a compatible assembly.
To silence this NuGet warning (and accepting that there may be issues at run-time when using a package originally authored for .NET Framework), you can add this NoWarn metadata to your package reference:
<PackageReference Include="My.Package" Version="1.2.3" NoWarn="NU1603" />