Dot-Net
建構後的 MsBuild 複製文件
我想
bin\Debug在建構項目後將一個 xml 文件從主目錄複製到,但我的解決方案不起作用。我編輯了.csproj文件並添加了:<Target Name="AfterBuild"> <Copy SourceFiles="Controllers.xml" DestinationFolder="\bin\Debug" ContinueOnError="true" /> </Target>我究竟做錯了什麼?建構成功。
您的目標文件夾(很可能)是錯誤的。如果您使用前導反斜杠指定它,它實際上只是
<current-drive-letter>\bin\Debug(使其有效地成為絕對路徑,如C:\bin\Debug)的簡寫形式。要麼使用
bin\Debug,要麼更好地使用OutputPath變數,該變數設置為bin\Debug或者bin\Release取決於您的建構配置。例子:
<Target Name="AfterBuild"> <Copy SourceFiles="Controllers.xml" DestinationFolder="$(OutputPath)" ContinueOnError="true" /> </Target>