Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

buildaction - Difference between Build action content and 'Copy to output directory' in Visual Studio

In my project in Visual Studio, I have files that I want included in the output, but not compiled or embedded.

I am aware that there are 2 ways to accomplish this.

  1. Setting the Build Action for the file to 'Content'
  2. Setting the 'Copy to Output Directory' to 'Copy Always' or 'Copy if newer'

Can someone tell me what the difference is and which scenario is each of the options appropriate for?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When setting the Build Action to Content, the file will not be compiled and will be put in the Content output group.

Whether the file gets copies or not depends on the Copy to Output Directory setting at that point.

Of course, if you set Copy Always on a file, it may get compiled and then copied.

See File Properties on MSDN:

Content - The file is not compiled, but is included in the Content output group. For example, this setting is the default value for an .htm or other kind of Web file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...