`dotnet build` fails when targeting .NET4.6
See original GitHub issueI’m creating a second issue because the first one dotnet/sdk#8334 has been closed without a solution and has not been reopened.
Steps to reproduce
Create a new solution using:
dotnet new sln --name TestSolution
Create and Add a class library project:
dotnet new classlib --name TestProject --output TestProject
dotnet sln add ./TestProject/TestProject.csproj
In TestProject.csproj change the TargetFramework property to net46
Restore and build the project using:
dotnet restore
dotnet build
Expected behavior
The project should build successfully.
Actual behavior
The project fails to build with the following error message:
E:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6" 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. [E:\Work\TestSolution\TestProject\TestProject.csproj]
However, when using msbuild
directly the build passes.
Furthermore, the solution builds with the following:
dotnet msbuild -p:FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6"
Environment data
dotnet --info
output:
.NET Command Line Tools (1.0.4)
Product Information: Version: 1.0.4 Commit SHA-1 hash: af1e6684fd
Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64 Base Path: E:\Program Files\dotnet\sdk\1.0.4
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:21 (7 by maintainers)
Top GitHub Comments
For me the only thing that worker (after installing all the targeting packs) was to repair the .NET Core SDK installation.
+1
I also have the very same issue.
I set up a new build machine (Windows Server 2012 R2 Standard). I installed the .net core 1.0.4 SDK on it. I also installed the Visual Studio 2017 Build tools as well as the .NET 4.6, 4.6.1 and 4.6.2 targeting packs.
The solution that fails to build one project is here: https://github.com/canonn-science/CanonnApi/tree/add-galmap/CanonnApi.Backend
The web api project builds correctly, but the Database.Autupdater project fails.
Environment data
The part of the build log that marks the error: