1

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 enter image description here

doublnt
  • 541
  • 9
  • 18
  • You have to edit the csproj file "by hand" with a text editor – Sir Rufo Mar 08 '19 at 06:05
  • 3
    Possible duplicate of [How do you multi-target a .NET Core class library with csproj?](https://stackoverflow.com/questions/42747977/how-do-you-multi-target-a-net-core-class-library-with-csproj) – Sir Rufo Mar 08 '19 at 06:14
  • @SirRufo I actually edit this csproj file by hand. But when I build the project, it output a error – doublnt Mar 08 '19 at 06:49
  • 3
    So please edit the question to show what you've done, and what the error is. – Jon Skeet Mar 08 '19 at 07:06
  • Use the visual studio installer, in the desktop development section you can enable and disable targeting packs, – Scott Chamberlain Mar 08 '19 at 09:02
  • 1
    Hmm... that works fine for me. It sounds like the .NET Core SDK can't find the reference assemblies for some reason. Which version of the .NET Core SDK are you using? Anything "odd" about your environment that's worth mentioning? – Jon Skeet Mar 08 '19 at 09:02

1 Answers1

0

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.

doublnt
  • 541
  • 9
  • 18
  • 1
    You just downloaded the wrong thing. What you need is the *developer pack*, it contains the files that you see back in a project's References node. Intention is not force your user to update his installed framework version. It is not clear why you like 4.7.1, but the developer pack download [is here](https://www.microsoft.com/en-us/download/details.aspx?id=56119). – Hans Passant Mar 08 '19 at 09:59