asp.net-mvc 发布 MVC 应用程序时如何包含自定义文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18601639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to include custom folders when publishing a MVC application?
提问by SamJolly
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.
我有一个带有徽标的“上传”文件夹。我希望 VS2012 一键发布包含此文件夹。目前不是。
How can I achieve this?
我怎样才能做到这一点?
采纳答案by Andrés Nava - Azure
I believe you need to set the folder's "Build Action" to "Content":
我相信您需要将文件夹的“构建操作”设置为“内容”:
回答by Abdul Rehman Sayed
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.
我为一个以 Angular 6 作为前端的 web api 项目(不是 dot net core)做了这个。我的 Visual Studio 版本是 2017 年。
I had created a wwwrootfolder where I was compiling angular files via custom build action & this folder was not included in my project.
我创建了一个wwwroot文件夹,我在其中通过自定义构建操作编译角度文件,该文件夹未包含在我的项目中。
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>
回答by Hugo Hilário
Go to Project Properties > Package / Publish Web
转到项目属性 > 打包/发布 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.
唯一的缺点是一切都在部署中,我不知道这是否是您想要的。
回答by saad elshazly
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.
就我而言,我在 bin 文件夹中创建了一个文件夹,并需要将该文件夹包含在发布中。那个代码对我有用。
<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.
希望能帮助某人。

