简体   繁体   中英

How do I fix Azure pipeline error NETSDK1152?

While running my pipeline, it fails at the publish phase with 2 errors.

##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1


##[error]Dotnet command failed with non-zero exit code on the following projects : ...

The pipeline also lists all paths to files with duplicate names, even if the contents are different. The pipeline worked fine before with the duplicate names, but now throws and error and will not proceed. what is the correct fix for this?

I think my pipeline is using Dotnet6 even though the app is only 3.1, and this was added to fix it. I don't know if this is the correct fix, but it is working.

I added this to the csproj files that have duplicate file names.

<PropertyGroup>
  <ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

This is where I found it. https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#erroronduplicatepublishoutputfiles

This is a breaking change introduced in .NET 6 https://learn.microsoft.com/en-us/do.net/core/compatibility/sdk/6.0/duplicate-files-in-output

You have multiple ways of fixing this:

  1. Evaluate your resources in the project where "CopyToOutputFolder" is set to "Always" and remove if they are unnecessary. How MSBuild handles this is, it tries to copy these resources to output folder after the build is completed.
  2. Target a specific SDK during the build by adding it in global.json https://learn.microsoft.com/en-us/do.net/core/versions/selection You probably have "rollForward" option set to "latestFeature" that automatically uses the latest SDK, so you can remove that and target .NET 5 or earlier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM