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.

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

1reaction
Gnbrkm41commented, Jun 28, 2020

Looks like it’s fixed in dotnet/runtime#38105. I cannot reproduce this issue on 5 P8.20326.16.

1reaction
YeskaNovacommented, Jun 17, 2020

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Strong Name Validation Failed
Option 1) Turn off code coverage (in VS 2010, go to Test Settings -› Data and Diagnostics -› Untick the "Enabled" box next...
Read more >
How to: Disable the strong-name bypass feature | ...
Bypassing the validation of strong-name signatures provides significant performance improvements. The bypass feature applies to any full-trust ...
Read more >
Apex Tutorials - Salesforce coding lessons for the 99%
Check out the full Apex Academy: Absolute Beginner's Guide to Coding in Salesforce ... On creation of a new record too, the name...
Read more >
Technical Notes 101 - QRadar 101
This error message occurs only when a user attempts to upgrade their QRadar V7.3.3 Console using an older WinCollect install file (SFS). Administrators...
Read more >
Strong name validation failed
Hi, I have the following problem: Our application consists of different solutions. All our solutions have a .snk keyfile.
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