In the .csproj file, what is <None Include = "..."> for?
how
<None Include="C:\foo.bar" /> differs from
<Content Include="C:\foo.bar" /> ?
The MSDN article on build action explains the differences.
No. The file is not part of the project output group and is not compiled during the build process. An example would be a text file containing documentation, such as a Readme file.
Content - The file is not compiled, but is included in the content output group. For example, this parameter is the default value for .htm or another type of web file.
One of the differences is how they are published; Elements "No" are not included in the publication, the elements "Content" do; for example, in the Application Files dialog box on the Publish tab.
I am not 100% sure (I read the MSDN description of the Build Action property), but just copying this answer from MSDN to StackOverflow does not fully answer the question.
The difference is None and Content only affects web projects. For a command line project, a WinForm project or UnitTest project (in my case), etc. No and Content have no other behavior.
MSDN: "project output group" or "content output group" only the terms used in the web project are used, right?
In my situation, the MSBuild file had an ItemGroup for image resources that looked like this:
<ItemGroup> <Content Include="Resources\image001.png" /> <Content Include="Resources\image002.png" /> <Content Include="Resources\image003.png" /> <Content Include="Resources\image004.png" /> <None Include="Resources\image005.png" /> <None Include="Resources\image006.png" /> <None Include="Resources\image007.png" /> </ItemGroup> While my project was building well, it made me wonder why I had a combination of Content and None elements in my ItemGroup . This MSDN article article (for Visual Studio 2010) gave me the guide I was looking for:
Note that when the resource editor adds an image, it sets the Assembly Action to No because the .resx file refers to the image file. During assembly, the image is inserted into the .resources file created from the .resx file. The image can be easily accessed using a strongly typed class automatically generated for the .resx file. Therefore, you should not change this setting to the Embedded Resource , as this will include the image twice in the assembly.
Resolution: Using this guide, using a text editor, I changed the Content type to None .
I have a project that does not contain compiled elements (it stores html and javascript for jasmine unit tests).
One day, my solution (containing the mentioned project) stopped compiling: "The target" Build "does not exist in the project."
I added import to run the compiler, which worked fine on my machine, but was not able to use msbuild on the build server.
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> Then I changed the line from
<None Include="SpecRunner.html" /> to
<Content Include="SpecRunner.html" /> and he also worked on the build server.
You need None in the template project file to include the files that you define in .vstemplate, otherwise they will be lost during the creation and translation process. They remain in the temp folder, which he uses to create everything, and then are deleted shortly afterwards.