c# - TFS 构建服务器 2015 - 转换 web.config 不正确
问题描述
我对 TFS 2015 构建服务器上的“visual studio build”任务有疑问。当我在构建服务器上构建我的项目时,它不会将转换后的 web.config 发布到正确的文件夹。我有两个 web.configs --> web(base).Debug.config 和 web(base).Release.config。
在以下文件夹中,我希望转换后的 web.config::...\TFS2015BuildAgent\work{tasknummer}\a_PublishedWebsites{backend solution}\web.config 但是转换后的 web.config 位于以下文件夹中:...\TFS2015BuildAgent \work{tasknummer}\a_PublishedWebsites\web.config
solution.csproj -文件有以下几行:
...
...
<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 任务规范下方:
- 视觉工作室版本:Visual Studio 2017
- MSBuild 参数:/p:OutDir=$(build.stagingDirectory) /p:SkipInvalidConfigurations=true /p:AllowedReferenceRelatedFileExtensions=none /p:DeployOnBuild=true
- 平台:任何cpu
- 配置:发布
- 干净:真
- MSBuild 架构:MSBuild x86
当我在 VS 2017 中构建我的项目(本地)时,web.config 已正确转换。此外,在本地发布时,web.config 会根据 de Debug 或 Release 配置正确转换。
但是,我已经为这个 TFS 服务器上的其他项目创建了多个构建定义,包括转换 web.config。在所有其他项目中,web.config 文件已正确/按预期转换......
所以我可能遗漏了一些东西....但是什么?
解决方案
经过几个小时的搜索,问题是 $(AssemblyName) 定义错误,因此配置文件被复制到了错误的文件夹中。
本地构建/发布可能没有问题,但是当 AssemblyName 不正确时,构建服务器上会出错。
推荐阅读
- postgresql - Is there a way to select elements associated with checked items without using multiple SELECT statements?
- angularjs - angularjs 组件控制器未将初始绑定值传递给模板中的指令(summernote)
- r - 如何总结与另一列的特定值相对应的列的组件?
- javascript - 在 JavaScript 中获取用户的本地 IP 地址?
- python - 碰撞评估中的故障状况
- reactjs - 在平板电脑上应对本机持久存储问题
- javascript - 我无法连接到本地主机上的服务器
- python - 运行 Flask 应用程序时导入有效,但直接运行文件时无效
- html-table - Bootstrap 5 - 表响应 - 不工作(对我来说)
- python-3.x - 是否可以使用 zip 文件中的烧瓶静态文件路径?