[英]TFS build server 2015 - Incorrect transform web.config
我在TFS 2015構建服務器上的“ Visual Studio構建”任務有問題。 當我在構建服務器上構建項目時,它不會將轉換后的web.config發布到正確的文件夾中。 我有兩個web.configs-> web(base).Debug.config和web(base).Release.config。
在以下文件夾中,我希望轉換后的web.config::... \\ TFS2015BuildAgent \\ work {tasknummer} \\ a_PublishedWebsites {后端解決方案} \\ web.config但是,轉換后的web.config在以下文件夾中:... \\ TFS2015BuildAgent \\ {工作} tasknummer \\ a_PublishedWebsites \\的web.config
solution.csproj -file具有以下幾行:
...
...
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
...
...
...
<Target Name="PostTransformAppConfig" AfterTargets="Build">
<CallTarget Targets="TransformWebConfig" />
<Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\webbase.config')" SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\webbase.config" DestinationFiles="Web.config" />
<Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\webbase.config')" SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\webbase.config" DestinationFiles="$(OutDir)\Web.config" />
<Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\webbase.config')" SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\webbase.config" DestinationFiles="$(OutDir)\_PublishedWebsites\$(AssemblyName)\Web.config" />
</Target>
...
...
...
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" Condition="false" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<PropertyGroup>
<PreBuildEvent>attrib -R "$(ProjectDir)Web.config"</PreBuildEvent>
</PropertyGroup>
在TFS服務器上的Visual Studio Build任務的規格下:
當我在VS 2017中構建我的項目(本地)時,正確轉換了web.config。 同樣,在本地發布它時,也會根據Debug或Release配置正確轉換web.config。
但是,我已經為該TFS服務器上的其他項目創建了多個構建定義,包括轉換web.config。 在所有其他項目上,web.config文件已正確/按預期進行了轉換。
因此,我可能會缺少一些東西。
經過幾個小時的搜索,問題在於$(AssemblyName)錯誤定義,因此配置文件被復制到錯誤的文件夾中。
本地構建/發布可能沒有問題,但是當有不正確的AssemblyName時,它將在構建服務器上出錯。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.