Meistros Labor
Meistros Labor

Reputation: 81

Generating a file during "Build", c#, Visual Studio

How can I generate a file during "Build" in Visual Studio using C#?

I want to create a .txt File and add some text in it. The file should be created directly when I press Build and save it in a place where the Release or Debug Folder is.

Upvotes: 4

Views: 1592

Answers (1)

Stefan
Stefan

Reputation: 17698

You should have a look at build events.

Typically you can run any kind of script pre and post build - including the (re)generation of a text file.

To copy files into the output path, you can use the OutputPath variable. See the MACRO section and this list on how to use them.

As by @Oliver's comment: if it is a static file, you can just include it in the project using its properties and select: Copy if newer.

Taken from the documentation:

enter image description here

And a subset of the MACROs

enter image description here

Upvotes: 6

Related Questions