2016-03-25 38 views
1

使用文件夾 - VS2013,VS2015,.NET 4.5Visual Studio的發佈 - 包括不添加到項目

我有幾個Asp.Net項目各自有包含圖像的1000的一個圖片/書籍文件夾中。我不在項目中包含這些文件夾(.csproj文件),因此在使用「發佈」時它們總是被忽略。

我想在發佈到UAT和LIVE時包含這些文件夾,而不必將它們添加到我的項目中,因爲項目中有太多圖像存在問題。

我需要做些什麼才能做到這一點?當您發佈從Visual Studio的Web應用程序這個鉤子工作:

回答

2

你可以用這個鉤子在您的項目文件中添加文件或文件夾部署:

<!--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> 

警告。這不適用於使用Team Foundation Server的發佈任務,因爲它不是任務CollectFilesFromContent,名爲

+0

仍然不確定如何將images/books文件夾中的所有圖像添加到發佈。你能詳細解釋一下嗎? – wingyip

相關問題