An alternative method is to simply leave elements like None . In Solution Explorer, select the ones you want to deploy and set the Content property to True .
Note: I did this in VS2019, and everything can change from version to version.
For this to work, right-click your project and select "Unload Project." Then right-click on the unloaded project and select "Change project_name .vcxproj".
In the editor, go to the bottom of the file and paste this target right in front of the end </Project> :
<Target Name="CopyContent" AfterTargets="Build"> <Copy SourceFiles="@(None)" Condition="'%(None.DeploymentContent)' == 'true'" DestinationFolder="$(OutputPath)" ContinueOnError="true" /> </Target>
Now right-click on the unloaded project and select "Update Project". Select to save and close if prompted.
I also set OutputDirectory to:
$(SolutionDir)bin\$(Configuration)\$(Platform)\
and IntermediateDirectory for:
$(SolutionDir)obj\$(Configuration)\$(ProjectName)\$(Platform)\
on the project properties common page. This puts the output in the bin folder, and the intermediate in the obj folder at the root of your solution.
Note: $(SolutionDir) not detected when starting MSBuild from the command line. There is a trick you can use to determine this for the folder the .sln file is in using GetDirectoryNameOfFileAbove. (left as an exercise for the reader). Also, it looks like in 2019 they are handling this correctly on the command line anyway. Yes :) $(SolutionDir) contains the trailing backslash, and therefore, none after it. The results of each must have a backslash.
Now, if you have Pro or higher, please do not do this every time you need to create a project. That would be lame. Instead, as soon as you set up your project as you like, choose β Project β Export Template . You give it a name, and the next time you want to create a project like this, just select that name in the New dialog box project. "(In the older version, I think it was Files β Export Teamplate... )