构建后的 MsBuild 复制文件

MsBuild copy file after build(构建后的 MsBuild 复制文件)
本文介绍了构建后的 MsBuild 复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想在构建项目后将一个 xml 文件从主目录复制到 binDebug,但我的解决方案不起作用.我编辑了 .csproj 文件并添加了:

I want to copy an xml file from the main directory to binDebug after building the project, but my solution doesn't work. I edited .csproj file and added:

<Target Name="AfterBuild">
     <Copy SourceFiles="Controllers.xml" DestinationFolder="inDebug" ContinueOnError="true" />
</Target>

我做错了什么?构建成功.

What am I doing wrong? The build is successful.

推荐答案

您的目标文件夹(很可能)错误.如果您使用前导反斜杠指定它,它实际上只是 <current-drive-letter>inDebug 的简写形式(使其有效地成为绝对路径,例如 C:inDebug).

Your destination folder is (most likely) wrong. If you specify it with a leading backslash, it is actually just a shortform for <current-drive-letter>inDebug (making it effectively an absolute path, like C:inDebug).

使用 binDebug,或者最好使用 OutputPath 变量,该变量设置为 binDebugbinRelease 取决于您的构建配置.

Either use binDebug, or better yet use the OutputPath variable, which is set to either binDebug or binRelease depending on your build configuration.

示例:

<Target Name="AfterBuild">
     <Copy SourceFiles="Controllers.xml" DestinationFolder="$(OutputPath)" ContinueOnError="true" />
</Target>

这篇关于构建后的 MsBuild 复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

MSBuild cannot find a reference(MSBuild 找不到参考)
The reference assemblies for framework .NETCore, Version=v5.0 were not found(未找到框架 .NETCore,Version=v5.0 的参考程序集)
quot;File has a different computed hash than specified in manifestquot; error when signing the EXE(“文件的计算哈希值与清单中指定的不同签署EXE时出错)
Good-practices: How to reuse .csproj and .sln files to create your MSBuild script for CI?(良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 MSBuild 脚本?)
Run an MSBuild target only if project is actually built(仅在实际构建项目时运行 MSBuild 目标)
MS-Build BeforeBuild not firing(MS-Build BeforeBuild 未触发)