Mimere
Mimere

Reputation: 783

Set Copy to Output folder by code

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.

Upvotes: 0

Views: 953

Answers (2)

mellamokb
mellamokb

Reputation: 56779

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

Upvotes: 0

Misko
Misko

Reputation: 2044

Try

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

Upvotes: 4

Related Questions