简体   繁体   English

如何修复 Azure 管道错误.NETSDK1152?

[英]How do I fix Azure pipeline error NETSDK1152?

While running my pipeline, it fails at the publish phase with 2 errors.运行我的管道时,它在发布阶段失败并出现 2 个错误。

##[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.我认为我的管道正在使用 Dotnet6,即使该应用程序只有 3.1,并且添加了它来修复它。 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.我将此添加到具有重复文件名的 csproj 文件中。

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

This is where I found it.这是我找到它的地方。 https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#erroronduplicatepublishoutputfiles 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这是 .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.评估“CopyToOutputFolder”设置为“始终”的项目中的资源,如果不需要则将其删除。 How MSBuild handles this is, it tries to copy these resources to output folder after the build is completed. MSBuild 的处理方式是,它会在构建完成后尝试将这些资源复制到 output 文件夹中。
  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.通过将其添加到 global.json https://learn.microsoft.com/en-us/do.net/core/versions/selection中,在构建期间针对特定的 SDK 您可能将“rollForward”选项设置为“latestFeature”自动使用最新的 SDK,因此您可以删除它并以 .NET 5 或更早版本为目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 构建管道 NuGet 还原错误 NETSDK1045 - Azure build pipeline NuGet Restore error NETSDK1045 如何修复 Azure Function 上的此 502 错误? - How do I fix this 502 Error on my Azure Function? 如何将自己的数据库与连接字符串中的(local)\\ netsdk关联? - How do I associate my own database with (local)\netsdk in the connection string? 如何修复错误 NETSDK1 project.assets.json 文件未找到。 运行 NuGet 包还原以生成此文件 - How to fix error NETSDK1 project.assets.json file not found. Run a NuGet package restore to generate this file 除以零错误,我该如何解决这个问题? - Divide by zero error, how do I fix this? 我该如何解决这个错误? “未处理 InvalidCastException” - How do I fix this error? “InvalidCastException was unhandled” 如何从测试项目修复 Azure Devops 构建错误 CS0246 - How do I fix Azure Devops build error CS0246 from test project 如何解决这个ajaxToolkit错误? - How do I fix this ajaxToolkit error? 如何解决通过管道传递所有对象输出时遇到的问题? - How do I fix the problem I have with passing all objects output via the pipeline? 如何修复数据库身份验证错误 - How do I fix a Database Authentication Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM