简体   繁体   English

msbuild 参数 /p:OutDir="$(build.artifactstagingdirectory)" 导致某些项目错过“bin/release”文件夹

[英]msbuild argument /p:OutDir="$(build.artifactstagingdirectory)" causing some projects to miss "bin/release" folder

I am working with a classic Azure build pipeline which is using the following MsBuild arguments for creating a package and zipping it:我正在使用经典的 Azure 构建管道,该管道使用以下 MsBuild 参数来创建包并对其进行压缩:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\"

The above arguments are creating an artifact but with too many nested folders.上述参数正在创建一个工件,但嵌套文件夹太多。 To avoid that I used this argument: based on this SO question: Avoid nested folders in zipped artifact为了避免这种情况,我使用了这个论点:基于这个 SO 问题: 避免在压缩工件中嵌套文件夹

/p:OutDir="$(build.artifactstagingdirectory)" /p:OutDir="$(build.artifactstagingdirectory)"

which fixed my one problem but now creating another.这解决了我的一个问题,但现在又创建了另一个问题。 The build solution task does not create the bin/release folder for some of the projects inside the solution and for that reason some of the copy tasks are failing.构建解决方案任务不会为解决方案中的某些项目创建bin/release文件夹,因此某些复制任务失败。

Build solution Task构建解决方案任务构建解决方案任务

Copy task复制任务批处理任务

Copy task failing due to missing bin/release由于缺少 bin/release 导致复制任务失败缺少垃圾箱释放

Copy task working for another project in the solution because bin/release folder exists for it复制为解决方案中的另一个项目工作的任务,因为它存在 bin/release 文件夹SYnc 项目复制任务

Nuget task is also failing due to missing bin/release folder由于缺少 bin/release 文件夹,Nuget 任务也失败了在此处输入图像描述

Is there any possibility to not miss the bin/release folders when passing /p:OutDir="$(build.artifactstagingdirectory) argument for avoiding nested folders structure for zipped artifact传递 /p:OutDir="$(build.artifactstagingdirectory) 参数以避免压缩工件的嵌套文件夹结构时,是否有可能不会错过 bin/release 文件夹

The $(OutDir) property is the Out put Dir ectory. $(OutDir) 属性是输出目录 This is the location where the project will produce its outputs.这是项目将产生其输出的位置。 The value of $(OutDir) may be bin\Release or bin\Debug (based on the current Configuration) within the project's directory. $(OutDir) 的值可能是项目目录中的 bin\Release 或 bin\Debug(基于当前配置)。

Specifying指定

/p:OutDir="$(build.artifactstagingdirectory)"

is overriding the output directory.正在覆盖输出目录。 The project will produce its outputs in the location given by $(build.artifactstagingdirectory).该项目将在 $(build.artifactstagingdirectory) 给出的位置生成其输出。 In your examples, because 'bin\Release' is overridden it won't be created by the project.在您的示例中,因为 'bin\Release' 已被覆盖,所以项目不会创建它。

Because the output directory was changed, the copy task should be changed to match.因为输出目录被改变了,所以拷贝任务应该被改变以匹配。 ie the source for the copy task should be $(build.artifactstagingdirectory).即复制任务的来源应该是$(build.artifactstagingdirectory)。

However, $(build.artifactstagingdirectory) is a variable that only exists in the context of the build pipeline.但是,$(build.artifactstagingdirectory) 是一个仅存在于构建管道上下文中的变量。 Overriding $(OutDir) with $(build.artifactstagingdirectory) can only be done within the pipeline which means that for a developer building in Visual Studio the build will behave differently.用 $(build.artifactstagingdirectory) 覆盖 $(OutDir) 只能在管道内完成,这意味着对于在 Visual Studio 中构建的开发人员,构建的行为会有所不同。 This discrepancy could cause confusion.这种差异可能会导致混淆。

If you are comfortable with MSBuild, you could add a custom target that is dependent on $(build.artifactstagingdirectory) having a value and on the packaging target being run ( AfterTargets="AfterPublish" ).如果您对 MSBuild 感到满意,则可以添加一个自定义目标,该目标取决于具有值的 $(build.artifactstagingdirectory) 和正在运行的打包目标 ( AfterTargets="AfterPublish" )。 The project will 'know' its packaging folder which, as an example, might be something like 'bin\Release\publish'.该项目将“知道”它的打包文件夹,例如,它可能类似于“bin\Release\publish”。 The custom target can copy from 'bin\Release\publish' to $(build.artifactstagingdirectory).自定义目标可以从 'bin\Release\publish' 复制到 $(build.artifactstagingdirectory)。

暂无
暂无

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

相关问题 复制 msbuild 之后的文件复制到根文件夹 $(build.ArtifactStagingDirectory) - Copying files after the msbuild do copy to the root folder $(build.ArtifactStagingDirectory) Azure 为 Windows 服务构建任务:- $(build.artifactstagingdirectory) 下没有 zip - Azure Build task for Windows Service :- no zip under $(build.artifactstagingdirectory) build.artifactstaging 目录不存在 Azure Devops - build.artifactstagingdirectory doesn't exist Azure Devops 我可以直接将文件保存到 $(Build.ArtifactStagingDirectory) 并发布它们吗? - Can I save files directly to $(Build.ArtifactStagingDirectory) and publish them? 在 Azure Dev Ops 上:如何查看 package 位置目录 $(Build.ArtifactStagingDirectory) 的内容 - On Azure Dev Ops: How do I view the content of the package location directory $(Build.ArtifactStagingDirectory) 我们能否在一个 azure-pipeline yaml 文件中为一个 repo 设置两个 Build.ArtifactStagingDirectory 位置以发布两个不同的 debian 安装程序 - Can we have two Build.ArtifactStagingDirectory location for one repo in one azure-pipeline yaml file to publish two different debian installer Azure Devops发布未经授权的某些项目管道 - Azure Devops release pipeline unauthorized for some projects MSBuild 在 Azure 构建服务器上忽略 /p:BuildProjectReferences=false - MSBuild ignoring /p:BuildProjectReferences=false on Azure build server 为什么 C:\Program Files\dotnet\sdk\3.1.201 中缺少 msbuild.exe? 导致 AzureDevOps 构建步骤失败 - Why is msbuild.exe missing in C:\Program Files\dotnet\sdk\3.1.201? Causing AzureDevOps build step to fail 构建/发布管道的执行是否会创建一个新的基础文件夹,其路径包含代理编号或构建/发布编号? - Does execution of build/release pipeline create a new base folder with the path containing agent number or build/release number?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM