sdk: `dotnet build` fails when targeting .NET4.6

I’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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 21 (7 by maintainers)

Most upvoted 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

C:\>dotnet --info
.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.3.9600
 OS Platform: Windows
 RID:         win81-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.4

C:\>

The part of the build log that marks the error:

[11:26:30][Step 1/2] C:\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. [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: The "GenerateRuntimeConfigurationFiles" task failed unexpectedly. [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\bin\Release\net46\win8-x64\Canonn.Database.AutoUpdater.runtimeconfig.json'. [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.WriteToJsonFile(String fileName, Object value) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.WriteRuntimeConfig(ProjectContext projectContext) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.ExecuteCore() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]

+1

+1