0

我的团队有一个包含 2 个项目的 Visual Studio 解决方案 - 1 个是 Umbraco 网站项目,另一个是名为 Core 的数据访问层。Umbraco 项目在构建时将数据访问层作为依赖项,并将 Umbraco 项目发布到 Azure 网站。

我们正在使用从 Azure 下载并导入解决方案并保存为 .pubxml 格式的发布配置文件 - 标准。

当我们在 Visual Studio 中进行发布时,Umbraco 项目会在部署到 Azure 之前将 Core 项目构建并编译为 .dll。这工作正常。

但是,此项目使用 TeamCity 与使用 Visual Studio (sln) 构建步骤构建的解决方案进行持续集成。在我们介绍第二个核心项目之前,它一直在正确构建/部署。

由于将第二个 Core 项目创建为依赖项,因此构建现在仅在 TeamCity 中失败。当我们仅将其保存在 Umbraco 项目(我们希望部署的项目)中时,它似乎正在两个项目中搜索发布配置文件。

我不确定问题出在哪里。我们只希望发布配置文件应用于我们希望部署的 Umbraco 项目,而不是只需要构建/编译的核心项目。

这是包含 MSBuild 输出的 TeamCity 构建配置输出:

[16:27:38] Checking for changes
[16:27:38] Collecting changes in 1 VCS root (1s)
[16:27:46] Building incremental patch for VCS root: Dev; checkout rules: =>; revision: 974f210ed3bdcb5b0f01cfd9f88fdd8335330cdd --> 974f210ed3bdcb5b0f01cfd9f88fdd8335330cdd
[16:27:41] Publishing internal artifacts
[16:27:41] Clearing temporary directory: C:\BuildAgent\temp\buildTmp
[16:27:41] Checkout directory: C:\BuildAgent\work\507e9be5fde8efc1
[16:27:41] Updating sources: server side checkout (5s)
[16:27:46] Step 1/4: Install NPM dependencies (Command Line) (1s)
[16:27:48] Step 2/4: Grunt tasks (Command Line) (3s)
[16:27:51] Step 3/4: Build solution and deploy (Visual Studio (sln)) (4s)
[16:27:52]   [Step 3/4] Starting: C:\BuildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\BuildAgent\work\507e9be5fde8efc1 "/msbuildPath:C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe"
[16:27:52]   [Step 3/4] in directory: C:\BuildAgent\work\507e9be5fde8efc1
[16:27:53]   [Step 3/4] Umbraco\Umbraco.csproj.teamcity: Build target: Build (2s)
[16:27:53]     [Umbraco\Umbraco.csproj.teamcity] CheckPrerequisites
[16:27:53]     [Umbraco\Umbraco.csproj.teamcity] RestorePackages
[16:27:54]     [Umbraco\Umbraco.csproj.teamcity] GetReferenceAssemblyPaths
[16:27:54]     [Umbraco\Umbraco.csproj.teamcity] ResolveProjectReferences (1s)
[16:27:54]       [ResolveProjectReferences] MSBuild (1s)
[16:27:54]         [MSBuild] Core\Core.csproj: Build default targets (1s)
[16:27:54]           [Core\Core.csproj] CheckPrerequisites
[16:27:54]           [Core\Core.csproj] RestorePackages
[16:27:54]           [Core\Core.csproj] GetReferenceAssemblyPaths
[16:27:54]           [Core\Core.csproj] ResolveAssemblyReferences
[16:27:55]           [Core\Core.csproj] CoreCompile
[16:27:55]           [Core\Core.csproj] _CopyAppConfigFile
[16:27:55]           [Core\Core.csproj] CopyFilesToOutputDirectory
[16:27:55]           [Core\Core.csproj] ValidatePublishProfileSettings
[16:27:55]             [ValidatePublishProfileSettings] GetPublishingLocalizedString
[16:27:55]             [ValidatePublishProfileSettings] GetPublishingLocalizedString
[16:27:55]               [GetPublishingLocalizedString] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4331, 5): The value for PublishProfile is set to 'publish-profile-dev', expected to find the file at 'C:\BuildAgent\work\507e9be5fde8efc1\Core\Properties\PublishProfiles\publish-profile-dev.pubxml' but it could not be found.
[16:27:55]             [ValidatePublishProfileSettings] GetPublishingLocalizedString
[16:27:55]               [GetPublishingLocalizedString] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4338, 4): PublishProfile(publish-profile-dev) is set. But the $(WebPublishMethod) does not have a valid value.  Current Value is "".
[16:27:55]             [ValidatePublishProfileSettings] Error
[16:27:55]               [Error] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4345, 5): Target ValidatePublishProfileSettings Failed
[16:27:55]   [Step 3/4] Process exited with code 1
[16:27:55]   [Step 3/4] MSBuild output
[16:27:55]     [MSBuild output] (GetReferenceAssemblyPaths target) -> 
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(989,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\BuildAgent\work\507e9be5fde8efc1\Umbraco\Umbraco.csproj.teamcity]
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output] "C:\BuildAgent\work\507e9be5fde8efc1\Umbraco\Umbraco.csproj.teamcity" (Build target) (1) ->
[16:27:55]     [MSBuild output] "C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj" (default target) (3) ->
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(989,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output] "C:\BuildAgent\work\507e9be5fde8efc1\Umbraco\Umbraco.csproj.teamcity" (Build target) (1) ->
[16:27:55]     [MSBuild output] "C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj" (default target) (3) ->
[16:27:55]     [MSBuild output] (ResolveAssemblyReferences target) -> 
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Transactions" culture="neutral" publicKeyToken="b77a5c561934e089" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="mscorlib" culture="neutral" publicKeyToken="b77a5c561934e089" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System" culture="neutral" publicKeyToken="b77a5c561934e089" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Data" culture="neutral" publicKeyToken="b77a5c561934e089" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Configuration" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Web" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Xml" culture="neutral" publicKeyToken="b77a5c561934e089" /><bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding> [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Windows\Microsoft.NET\Framework\v4.0.30319\\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Data", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.EnterpriseServices", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Web", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output] "C:\BuildAgent\work\507e9be5fde8efc1\Umbraco\Umbraco.csproj.teamcity" (Build target) (1) ->
[16:27:55]     [MSBuild output] "C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj" (default target) (3) ->
[16:27:55]     [MSBuild output] (ValidatePublishProfileSettings target) -> 
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4331,5): error : The value for PublishProfile is set to 'publish-profile-dev', expected to find the file at 'C:\BuildAgent\work\507e9be5fde8efc1\Core\Properties\PublishProfiles\publish-profile-dev.pubxml' but it could not be found. [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4338,4): error : PublishProfile(publish-profile-dev) is set. But the $(WebPublishMethod) does not have a valid value.  Current Value is "". [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output]   C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4345,5): error : Target ValidatePublishProfileSettings Failed [C:\BuildAgent\work\507e9be5fde8efc1\Core\Core.csproj]
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output]     7 Warning(s)
[16:27:55]     [MSBuild output]     3 Error(s)
[16:27:55]     [MSBuild output] 
[16:27:55]     [MSBuild output] Time Elapsed 00:00:02.37
[16:27:56]   [Step 3/4] Step Build solution and deploy (Visual Studio (sln)) failed
[16:27:56] Step 4/4: Fin. (Command Line)
[16:27:56] Publishing internal artifacts
[16:27:57] Build finished

关于如何解决这个问题的任何想法?

编辑:以下是 Visual Studio (sln) 构建步骤中包含的构建参数:

DeployOnBuild       True
ExcludeFoldersFromDeployment        App_Data\Logs;App_Data\preview;Build
Password        biglongazurepasswordwhichiveobfuscated
ProfileTransformWebConfigEnabled        False
PublishProfile      publish-profile-dev
PublishProfileRootFolder        %teamcity.build.checkoutDir%\Umbraco\Properties\PublishProfiles
4

1 回答 1

0

为此找到了非常简单的修复程序。Core 项目已作为 Web 应用程序添加到 Visual Studio,而不是类库。所以它总是会尝试发布它。

实际修复是更新 Core.csproj 文件中的 GUID,根据https://stackoverflow.com/a/10878686/4498130

于 2015-03-13T12:03:42.280 回答