Hello world targeting .NET 5.0 master nightly fails to build using VS due to strong name validation failure
See original GitHub issue(Very likely that I’m in the wrong repo, please feel free to move this to the correct repo if that is the case)
Currently I have 5.0.100-preview.7.20315.4 SDK Installed using the installer from the dotnet/installer repo. FWIW, I’m using one of the Windows 10 Pro Insiders (ko-KR, Fast ring, 19645) builds.
Using VS2019 Community 16.7 P2, I am unable to build a hello world project created using the default console app template.
ConsoleApp35.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
Program.cs:
using System;
namespace ConsoleApp35
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Build log:
1>------ Build started: Project: ConsoleApp35, Configuration: Debug Any CPU ------
1>You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: File name: 'System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: The Zone of the assembly that failed was:
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: MyComputer
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.NET.HostModel.AppHost.MachOUtils.RemoveSignature(String filePath)
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.NET.HostModel.AppHost.HostWriter.<>c__DisplayClass2_0.<CreateAppHost>g__RemoveSignatureIfMachO|2()
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.NET.HostModel.RetryUtil.RetryOnIOError(Action func)
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom)
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore()
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute()
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018:
1>C:\Program Files\dotnet\sdk\5.0.100-preview.7.20315.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(428,5): error MSB4018:
1>Done building project "ConsoleApp35.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The build process seemingly does nothing for about a minute… then it just fails with the error above.
Funnily enough… if I attempt this using dotnet build
from CLI it seems to run just fine. This also happens with an other project of mine that also targets net5.0.
Attaching the binary log file from VS and CLI for comparison purposes. (Please remove the trailing .log
extension, I had to change its extension because GitHub won’t allow binlog files by default)
cli.binlog.log
vs.binlog.log
Any clues on troubleshooting would be appreciated.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9
Top GitHub Comments
Looks like it’s fixed in dotnet/runtime#38105. I cannot reproduce this issue on 5 P8.20326.16.
@Gnbrkm41 If you have .net sdk 5.xx installed, you have to set in global.json a 3.xx version if you want to build a 3.xx project without having that problem. Otherwise you have to uninstall 5.xx sdk