MsBuild copy file after build(构建后的 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 变量,该变量设置为 binDebug 或 binRelease 取决于您的构建配置.
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 复制文件
基础教程推荐
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 将数据集转换为列表 2022-01-01
- 如果条件可以为空 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 获取C#保存对话框的文件路径 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
