sdk: Web Application build error with net6.0 framework, Failed to sign apphost with error code 0
Web Application build error with net6.0 framework.
I am working on MAC and dotnet core 3.1, 5.0 and 6.0 versions are installed on my machine. I not able to build Web Application on my machine due to shared error in this ticket.
I can build web application in target framework net5.0 but not with net6.0 and console, class library projects’ build successfully. I tried to build using command line, VS 2022/2019 but no success.
Project file code as below and this is empty Web API project.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.5" />
</ItemGroup>
</Project>
To Reproduce
Exceptions (if any)
/usr/local/share/dotnet/sdk/6.0.100-rc.2.21505.57/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(5,5): Error NETSDK1177: Failed to sign apphost with error code 0: /Users/ajandersingh/Projects/WebAppTest/WebAppTest/obj/Debug/net6.0/apphost: is already signed (NETSDK1177) (WebAppTest)
Further technical details

- Include the output of
dotnet --info - VS 2022 Preview and VS 2019
Please assist to resolve code build error. I apologies if I have posted issue is not relevant to reported category
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 3
- Comments: 33 (10 by maintainers)
sudo xcode-select -rfixing the issue for me…I had this problem today, where it failed to sign apphost since it is already signed. It resolved itself and disappeared once I had installed the latest .Net SDK (6.0.202).
I started by trying out the other suggestions, with xcode etc, but this fixed in the end.
Captured a binlog, but it doesn’t show anything other than
CreateAppHostbeing called, with the code signing flag passed through correctly.With
_EnableMacOSCodeSignset false:Without
_EnableMacOSCodeSignset false:Nothing surprising there.
Digging into the implementation of
CreateAppHost, I see it tries to remove the existing signature before sending it on to be signed:That method returns a boolean success/fail code, but it isn’t checked here and I don’t see any debug logging. Its implementation is here, and appears to have several places where it could exit early if it didn’t detect the type of signature it is expecting. My guess is that something changed with this last macOS 12.3.1 update that makes that code fail on x64-built files (or perhaps just x64-built files when running the code from an arm64 machine under Rosetta?)
Some other clues I just noticed from the signature in my previous post, the
Format=Mach-O thin (x86_64)as well as theIdentifierstarting withfunc-notapphost-.Here is my recollection of the time line for my experience with this issue. Hope this helps.
Time Line
Questions for the MS Folks: