【问题标题】:Visual Studio Publish - Include folder that is not added to ProjectVisual Studio 发布 - 包含未添加到项目的文件夹
【发布时间】:2016-03-25 11:43:37
【问题描述】:

使用 - VS2013、VS2015、.Net 4.5

我有几个 Asp.Net 项目,每个项目都有一个包含 1000 张图像的 images/books 文件夹。我没有在项目(.csproj 文件)文件中包含这些文件夹,因此在使用 Publish 时它们总是被忽略。

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

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

【问题讨论】:

    标签: visual-studio msbuild


    【解决方案1】:

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

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

    【讨论】:

    • 仍然不确定如何将 images/books 文件夹中的所有图像添加到发布中。你能详细说明一下吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 2010-10-19
    相关资源
    最近更新 更多