Visual Studio发布-未添加到Project的包含文件夹 [英] Visual Studio Publish - Include folder that is not added to Project

查看:75
本文介绍了Visual Studio发布-未添加到Project的包含文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用-VS2013,VS2015,.Net 4.5

Using - VS2013, VS2015, .Net 4.5

我有几个Asp.Net项目,每个项目都有一个images/books文件夹,其中包含1000张图像.我没有将这些文件夹包括在项目(.csproj文件)文件中,因此在使用发布"功能时,它们始终会被忽略.

I have several Asp.Net projects each of which has an images/books folder that contains 1000's of images. I don't include these folders in the project ( the .csproj file) files so they are always left out when using using Publish.

我想在发布到UAT和LIVE时包括这些文件夹,而不必将它们添加到我的项目中,因为项目中有太多图像是有问题的.

I want to include these folders when publishing to UAT and LIVE without having to add them to my project as having so many images in your project is problematic.

我需要怎么做才能做到这一点?

What do I need to do to make this happen?

推荐答案

您可以在项目文件中使用此挂钩添加要部署的文件或文件夹:

You can use this hook in your project file to add files or folder to deploy :

 <!--Hook to deploy add files -->
 <PropertyGroup>
      <CollectFilesFromContentDependsOn>
           AddFilesToDeploy;
           $(CollectFilesFromContentDependsOn);
      </CollectFilesFromContentDependsOn>
 </PropertyGroup>
 <!--Add files to deploy -->
 <Target Name="AddFilesToDeploy">
      <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
           <Output TaskParameter="Assemblies" ItemName="CurrentAssembly" />
      </GetAssemblyIdentity>
      <ItemGroup>
           <JsFile Include="App\MyApp.min-%(CurrentAssembly.Version).js" />
           <FilesForPackagingFromProject Include="%(JsFile.Identity)">
                <DestinationRelativePath>App\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
           </FilesForPackagingFromProject>
      </ItemGroup>
 </Target>

警告:当您从Visual Studio发布Web应用程序时,此挂接工作.这不适用于Team Foundation Server的发布任务,因为调用的不是CollectFilesFromContent任务

Warning : this hook work when you publish a web application from visual studio. This doesn't work with the publish task with Team Foundation Server because it's not the task CollectFilesFromContent that is called

这篇关于Visual Studio发布-未添加到Project的包含文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆