【问题标题】:How to exclude APP_DATA directory from publishing using custom target "PublishToFileSystem"如何使用自定义目标“PublishToFileSystem”从发布中排除 APP_DATA 目录
【发布时间】:2017-01-04 12:23:19
【问题描述】:

我正在使用自定义目标将我的网站发布到本地文件夹。

目标(找到here)看起来像:

<Target Name="PublishToFileSystem"
        DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
    <Error Condition="'$(PublishDestination)'==''"
           Text="The PublishDestination property must be set to the intended publishing destination." />
    <MakeDir Condition="!Exists($(PublishDestination))"
             Directories="$(PublishDestination)" />

    <ItemGroup>
        <PublishFiles Include="$(_PackageTempDir)\**\*.*" />
    </ItemGroup>

    <Copy SourceFiles="@(PublishFiles)"
          DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')"
          SkipUnchangedFiles="True" />
</Target>

对应的msbuild命令如下:

msbuild projectfile.csproj /p:DeployOnBuild=true /p:VisualStudioVersion=14.0 /p:configuration=Release /p:PublishDestination=C:\inetpub\wwwroot\WebSite /T:PublishToFileSystem

到目前为止效果很好。但是,我想从发布中排除 APP_DATA 目录。

那么,有没有办法从发布中排除 APP_DATA 目录?也许通过将其从&lt;PublishFiles Include="$(_PackageTempDir)\**\*.*" /&gt; 定义的文件集中排除?

环境: 视觉工作室 2015 MSBuild 工具 2015

【问题讨论】:

    标签: asp.net web build msbuild


    【解决方案1】:

    我发现最简单的方法是在发布配置文件中进行设置。

    <ExcludeApp_Data>False</ExcludeApp_Data>
    

    【讨论】:

      【解决方案2】:

      您可以从解决方案属性中执行此操作。只需右键单击解决方案并选择其属性。您将在此处获得“打包/发布”选项卡,您只需检查“从 App_Data 文件夹中排除文件”。您可以查看附加的屏幕截图。 希望对你有帮助。

      【讨论】:

      • 感谢您的回答。不幸的是,我正在使用 VS2015 (MSBuild ToolsVersion 14.0),该选项不再可用。关于this post,该选项已移至 pubxml 文件(这不是我的发布过程的一部分)。
      【解决方案3】:

      可以在项目文件中设置选项(@Vipin Rathore 建议):

      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
          <ExcludeFoldersFromDeployment>APP_DATA</ExcludeFoldersFromDeployment>
      </PropertyGroup>
      

      【讨论】:

        猜你喜欢
        • 2010-12-11
        • 2023-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-14
        • 1970-01-01
        • 2010-10-23
        • 1970-01-01
        相关资源
        最近更新 更多