Visual Studio publish fails because of nuget authorization and works after successfull manual msbuild publish

Anonymous
2023-03-03T08:49:08.2833333+00:00

Hello,

i was trying to publish a .net 6 project as self-contained with the following publish profile:
User's image

This resulted in the following error message:

The plugin credential provider could not acquire credentials. Authentication may require manual action. Consider re-running the command with --interactive for dotnet, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for NuGet

I then tried several steps found on the internet to solve this including removing all kinds of Nuget account information or Nuget feeds to get VS to let me reenter the credentials again. All without success.

I then tried to run msbuild with the following command:
MSBuild.exe /target:publish /p:NuGetInteractive="true" /p:PublishDir="(targetDir)" /p:PublishProfile="(PathToProject)\Properties\PublishProfiles\FolderProfile.pubxml"

This did not work because of error NETSDK1047. We have no runtime identifier in the csproj, just the targetframework "net6" which seems to be a problem for msbuild. After adding the RuntimeIdentifier from the PublishProfile in our csproj and running dotnet restore the msbuild publish started working because Nuget added the runtime-information to the project.assets.json file.

The interesting thing is that after i could build successfully via cmd and msbuild one time the publish in Visual Studio started working again so it seems to be some Nuget credential cache related issue.

Any help or information regarding this is highly appreciated since multiple members of my team had this publish issue too.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,596 questions
{count} vote