Set Copy to Output folder by code

核能气质少年 提交于 2020-01-17 05:20:28

问题


I am developing a code generation tool, so the project files(.csprj) are created by code. Is there any way to mark a content file to be copied always to the output directory? ...

var project = new BuildEngine.Project();
project.Load(ProjectFile.FullName, ProjectLoadSettings.IgnoreMissingImports);
var buildItem = project.AddNewItem("Content", fileName);   

... I need something like this buildItem.CopyToOutput=true...

project.Save(ProjectFile.FullName);

Every ideas are welcome. Thank you.


回答1:


Try

buildItem.SetMetadata("CopyToOutputDirectory", "Always");



回答2:


<Content Include="My.File">
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>


来源:https://stackoverflow.com/questions/5032430/set-copy-to-output-folder-by-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!