
8

MSBuild 生成/发布后将文件复制到指定目录
source link: https://azhuge233.com/msbuild-%e7%94%9f%e6%88%90-%e5%8f%91%e5%b8%83%e5%90%8e%e5%b0%86%e6%96%87%e4%bb%b6%e5%a4%8d%e5%88%b6%e5%88%b0%e6%8c%87%e5%ae%9a%e7%9b%ae%e5%bd%95/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

MSBuild 生成/发布后将文件复制到指定目录Skip to content
在 .csproj 文件中添加
<Target Name="YourNameHere" AfterTargets="Publish/AfterBuild/...">
<Copy SourceFiles="file\path\here" DestinationFolder="$(PublishDir)/$(OutDir)/..." />
<Copy ... />
</Target>
<Target Name="YourNameHere" AfterTargets="Publish/AfterBuild/..."> <Copy SourceFiles="file\path\here" DestinationFolder="$(PublishDir)/$(OutDir)/..." /> <Copy ... /> </Target>
<ItemGroup>
<None Update="file\path\here" CopyToOutputDirectory="PreserveNewest/Always" />
<None ... />
</ItemGroup>
<ItemGroup> <None Update="file\path\here" CopyToOutputDirectory="PreserveNewest/Always" /> <None ... /> </ItemGroup>
第二种方法会将项目目录原封不动复制到发布/生成目录,例如:
项目目录中的 Config 文件夹下有 test.config 文件
- 第一种复制方式可以在 DestinationFolder 指定 test.config 被复制到发布/生成目录的哪个文件夹下
- 第二种会直接在发布/生成目录下新建 Config 文件夹再将 test.config 复制其中,无法指定 test.config 的位置
相关
此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK