我的团队有一个Visual Studio解决方案,其中包含2个项目 - 1个是Umbraco网站项目,另一个是名为Core的数据访问层。 Umbraco项目在构建时将数据访问层作为依赖项,将Umbraco项目发布到Azure网站。
我们正在使用从Azure下载并导入到解决方案中的发布配置文件,并以.pubxml格式保存 - 标准。
当我们在Visual Studio中进行发布时,Umbraco项目会在部署到Azure之前构建并编译Core项目作为.dll。这很好用。
但是,该项目使用TeamCity与使用Visual Studio(sln)构建步骤构建的解决方案持续集成。在我们介绍第二个Core项目之前,它已经正确构建/部署。
由于将第二个Core项目创建为依赖项,因此构建现在仅在TeamCity中 。当我们只将它保存在Umbraco项目(我们希望部署的项目)中时,它似乎是在 两个 项目中搜索发布配置文件。
我不确定问题出在哪里。我们只希望将发布配置文件应用于我们希望部署的Umbraco项目,而不是仅需要构建/编译的Core项目。
这是TeamCity构建配置输出,包括MSBuild输出:
[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
答案 0 :(得分:0)
为此找到了非常简单的修复程序。 Core项目已作为Web应用程序添加到Visual Studio,而不是类库。所以它总是试图发布它。
实际修复是根据https://stackoverflow.com/a/10878686/4498130更新Core.csproj文件中的GUID