问题
I have an "Uploads" folder with logos within in. I would like the VS2012 one-click publish to include this folder. Currently it is not.
How can I achieve this?
回答1:
I believe you need to set the folder's "Build Action" to "Content":
What are the various "Build action" settings in Visual Studio project properties and what do they do?
回答2:
I did this for a web api project (not dot net core) which had Angular 6 as a front end. My visual studio version was 2017.
I had created a wwwroot folder where I was compiling angular files via custom build action & this folder was not included in my project.
I edited the project file & added these lines.
<PropertyGroup>
<PipelineCollectFilesPhaseDependsOn>
CustomCollectFiles;
$(PipelineCollectFilesPhaseDependsOn);
</PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<Message Text="Inside of CustomCollectFiles" Importance="high" />
<ItemGroup>
<_CustomFiles Include="wwwroot\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>wwwroot\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
回答3:
Go to Project Properties > Package / Publish Web
Then select the configuration combo that you want to setup up.
Below you have the Items to deploy. I just tested here with "All files in this project folder" and everything was published.
The only downside is that everything is getting deployed, I don't know if this is what you want.
回答4:
in my case i Created a folder in the bin folder and needed to include that folder in the publish. and that code is worked for me.
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include=".\bin\Dlls\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\Dlls\%(RecursiveDir)%(Filename)%(Extension)
</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>CustomCollectFiles;
;</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>CustomCollectFiles;
;</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
hope that helps someone.
来源:https://stackoverflow.com/questions/18601639/how-to-include-custom-folders-when-publishing-a-mvc-application