[英]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文件夹,因此某些复制任务失败。
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 文件夹
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.