Web Application build error with net6.0 framework, is already signed (NETSDK1177)
Asked Answered
B

3

8

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>

Exception

/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/abc/Projects/WebAppTest/WebAppTest/obj/Debug/net6.0/apphost: is already signed (NETSDK1177) (WebAppTest)

Further technical details

.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.2.21505.57
 Commit:    ab39070116

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.6
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100-rc.2.21505.57/

Host (useful for support):
  Version: 6.0.0-rc.2.21480.5
  Commit:  6b11d64e7e

.NET SDKs installed:
  3.1.414 [/usr/local/share/dotnet/sdk]
  5.0.402 [/usr/local/share/dotnet/sdk]
  6.0.100-rc.2.21505.57 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.20 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
Buster answered 20/10, 2021 at 9:2 Comment(2)
Did you fix this issue? I am facing the same problem.Hosier
No, this not fixed yet, I also raised issue with detnet devlopment team dotnet/sdk You can check status and add you comments. Please let me know if you have found any soultion. ThanksBuster
O
11

This problem is being tracked in https://github.com/dotnet/sdk/issues/22201. It appears to have resurfaced around March 2022, with the macOS 12.3.1 update.

One workaround is to disable code signing. This is slightly better than disabling the app host creation completely.

You can do this either by /p:_EnableMacOSCodeSign=false on the dotnet command, or the following in your csproj:

<PropertyGroup>
   <_EnableMacOSCodeSign>false</_EnableMacOSCodeSign>
</PropertyGroup>

Or if you're running JetBrains Rider, consider adding it as an MSBuild global property:

screenshot

Oleomargarine answered 5/4, 2022 at 18:15 Comment(0)
S
2

Just add

 <UseAppHost>false</UseAppHost>

to your property group in the csproj or set the value to false.

Strohbehn answered 7/5, 2022 at 20:49 Comment(0)
R
0

I had a similar issue on a Mac using dotnet 6, which is a console application described in: https://learn.microsoft.com/en-us/learn/modules/work-with-cosmos-db/3-exercise-work-cosmos-db-dotnet

After looking around, the fix for me was to editing the project file and adding:

<PropertyGroup>
...
  <UseAppHost>true</UseAppHost>
...
</PropertyGroup> 
Rage answered 27/11, 2021 at 2:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.