msbuild参数 /p:outdir=" quot; Quot.ArtifactStagingDirectory)"导致一些项目错过了“ bin/preasoy”。文件夹

发布于 2025-02-13 02:26:33 字数 1962 浏览 1 评论 0 原文

我正在使用经典的Azure Build Pipeline,该管道使用以下MSBUILD参数来创建软件包并将其拉开:

/p:deployonbuild = true/p:webpublishmethod = package /p:packageassinglefile = true/p:skipinvalidconfigurations = true /p:packageLocation =“ $(build.ArtifactStagingDirectory)\”

上面的参数正在创建一个工件,但嵌套了太多。为了避免我使用了这个参数:基于这个问题:避免在拉链中避免嵌套文件夹

/p:OutDir =“ $(build.ArtifactStagingDirectory)”

它解决了我的一个问题,但现在创建了另一个问题。构建解决方案任务并未为解决方案中的某些项目创建 bin/Release 文件夹,因此某些复制任务正在失败。

构建解决方案任务

复制任务

复制任务由于缺少bin/realease 而失败

复制解决方案中的另一个项目的任务,因为bin/preame文件夹存在

nuget任务也因缺少bin/preasion文件夹而失败

是否有可能在通过时不错过垃圾箱/释放文件夹/p:outdir="$(build.ArtifactStagingDirectory)避免嵌套文件夹结构的论点< /strong> < /strong>

I am working with a classic Azure build pipeline which is using the following MsBuild arguments for creating a package and zipping it:

/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

/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.

Build solution Task
Build solution task

Copy task
Batch task

Copy task failing due to missing bin/release
MIssing bin release

Copy task working for another project in the solution because bin/release folder exists for it
SYnc Project copy task

Nuget task is also failing due to missing bin/release folder
enter image description here

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以歌曲疗慰 2025-02-20 02:26:33

$(OUTDIR)属性是 OUT put dir ectory。这是项目产生其输出的位置。 $(OUTDIR)的值可以是项目目录中的bin \ Release \ Release \ debug(基于当前配置)。

指定

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

正在覆盖输出目录。该项目将在$(build.ArtifactStagingDirectory)给出的位置产生其输出。在您的示例中,因为“ bin \ realease”被覆盖了它不会由项目创建。

由于更改了输出目录,因此应更改复制任务以匹配。即复制任务的来源应为$(build.ArtifactStagingDirectory)。

但是,$(build.ArtifActStagingDirectory)是一个仅在构建管道上下文中存在的变量。用$(build.ArtifactStagingDirectory)覆盖$(OUTDIR)只能在管道中完成,这意味着对于Visual Studio中的开发人员建筑物而言,构建的行为会有所不同。这种差异可能会引起混乱。

如果您对MSBUILD感到满意,则可以添加一个定制目标,该目标取决于$(build.ArtifactStagingDirectory)具有值和正在运行的包装目标( AfterTargets =“ AfterPublish” )。该项目将“知道”其包装文件夹,例如,它可能是“ Bin \ Release \ Publish”之类的。自定义目标可以从'bin \ Release \ Publish'到$(build.ArtifactStagingDirectory)复制。

The $(OutDir) property is the Output Directory. 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.

Specifying

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

is overriding the output directory. The project will produce its outputs in the location given by $(build.artifactstagingdirectory). In your examples, because 'bin\Release' is overridden it won't be created by the project.

Because the output directory was changed, the copy task should be changed to match. i.e. the source for the copy task should be $(build.artifactstagingdirectory).

However, $(build.artifactstagingdirectory) is a variable that only exists in the context of the build pipeline. 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. 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"). The project will 'know' its packaging folder which, as an example, might be something like 'bin\Release\publish'. The custom target can copy from 'bin\Release\publish' to $(build.artifactstagingdirectory).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文