Microsoft.WebApplication.targets + Disable_CopyWebApplication = True并不阻止csproj创建_PublishedWebsites文件夹

时间:2018-02-14 14:41:55

标签: asp.net visual-studio msbuild

有一个虚拟项目+一个应用xslt转换的控制台项目,所以他们在各自的.csproj文件中使用Microsoft.WebApplication.targets,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{39560935-7551-4789-9666-4A48AD0FE3C7}</ProjectGuid>
    <OutputType>Library</OutputType>
    <RootNamespace>...</RootNamespace>
    <AssemblyName>...</AssemblyName>
    <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    **<Disable_CopyWebApplication>True</Disable_CopyWebApplication>**
</PropertyGroup>
[...]
<PropertyGroup>
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
  <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<UsingTask TaskName="TransformXml" AssemblyFile="$(VSToolsPath)\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="BeforeBuild">
  <Exec Command=".\.nuget\nuget.exe restore .\packages.config -PackagesDirectory .\..\packages" />
  <Delete Files="Config\ConnectionStrings\ConnectionStrings.config" />
  <Message Text="=====================================================================================================================================================" />
  <Message Text="Applying XSLT transformations (Disable_CopyWebApplication='$(Disable_CopyWebApplication)') using 'Microsoft.WebApplication.targets' from:" />
  <Message Text="" />
  <Message Text="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" />
  <Message Text="" />
  <TransformXml Source="Config\ConnectionStrings\ConnectionStrings.base.config" Transform="Config\ConnectionStrings\ConnectionStrings.$(Configuration.Replace('dbg@', '').Replace('rls@', '')).config" Destination="Config\ConnectionStrings\ConnectionStrings.config" />
  <Message Text="=====================================================================================================================================================" />
</Target>

要在我们的构建服务器中为所述项目生成生产版本,我们就像这样构建它们:

<MSBuild    Projects="$(_solutionFile)"
            Targets="$(TargetProject)"
            Properties="Platform=$(Platform);OutputPath=$(PublishUrl);Configuration=$(Configuration);"
            ToolsVersion="15.0"
/>

如上所示,我们采用

<Disable_CopyWebApplication>True</Disable_CopyWebApplication>

仍然会创建_PublishedWebsite文件夹。我们在这里可以缺少什么?

更新

根据我们在.csproj文件中放置的调试语句&#34; Microsoft.WebApplication.targets&#34;在构建期间使用的是这个:

 "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets"

复制&#34;网站的内部任务&#34; (在我们的例子中是exe)是这样的:

<Target Name="_CopyWebApplication"
        Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'"
        DependsOnTargets="$(_CopyWebApplicationDependsOn)">

  <CallTarget Condition="'$(OnAfter_CopyWebApplication)' != ''" Targets="$(OnAfter_CopyWebApplication)" RunEachTargetSeparately="true" />

</Target>

此任务似乎按预期工作,因为事实证明_PublishedWebsite 包含exe-project的已编译dll的任何它仅包含具有以下文件夹结构的roslyn dlls / exes

 <Project_Output_Folder>\_PublishedWebsites\<Project.Name.Here>\bin\roslyn

我认为包含了nuget包:

 Microsoft.Net.Compilers

和/或

 Microsoft.CodeDom.Providers.DotNetCompilerPlatform

导致问题的原因。正在使用的nuget包是:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.2.0" targetFramework="net471" allowedVersions="[6.2.0]" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net471" allowedVersions="[1.0.8]" />
  <package id="Microsoft.Net.Compilers" version="2.6.1" targetFramework="net471" developmentDependency="true" allowedVersions="[2.6.1]" />
  <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net471" allowedVersions="[10.0.3]" />
  <package id="Oracle.ManagedDataAccess" version="12.2.1100" targetFramework="net471" allowedVersions="[12.2.1100]" />
  <package id="Oracle.ManagedDataAccess.EntityFramework" version="12.2.1100" targetFramework="net471" allowedVersions="[12.2.1100]" />
  <package id="StructureMap" version="4.6.1" targetFramework="net471" allowedVersions="[4.6.1]" />
  <package id="System.Reflection.Emit.Lightweight" version="4.3.0" targetFramework="net471" allowedVersions="[4.3.0]" />
</packages>

所以我想这个问题归结为如何让Compilers包尊重我们设置的dont-copy标志?

0 个答案:

没有答案