question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`dotnet build` fails when targeting .NET4.6

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
labmoralescommented, Jun 27, 2019

For me the only thing that worker (after installing all the targeting packs) was to repair the .NET Core SDK installation.

2reactions
gingterscommented, Jul 15, 2017

+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]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot .NET Framework targeting errors
To resolve the error, make sure that your application targets a .NET version that's compatible with the version that's targeted by the projects ......
Read more >
The reference assemblies for framework ".NETFramework ...
I've tried installing the .NET Framework 4.6.2 SDK, as well as the 4.6 Targeting Pack, however both error that I already have it...
Read more >
AzurePipeline failing due to: The reference assemblies for . ...
BuildTime.targets(73,5): Error CGR1001: CodeGeneration.Roslyn.Tool (dotnet-codegen) is not available, code generation won't run.
Read more >
Building a project that target .NET Framework 4.5 in Visual ...
So, the fix is simple: just copy the files from that package to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4 ...
Read more >
Multi-targetting .Net Framework and .Net Core in a single project
A 15-second guide and 15-minute walk through. You have a .Net Core project, whether a netstandard library, or a netcore app, and you'd...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found