Msbuild忽略azure发布配置文件设置 - Visual Studio 2015 - .Net 4.6.1

问题描述 投票:1回答:2

我的解决方案中有2个Web API项目。一个项目是4.5.1,另一个项目是4.6.1。

使用.Net framework 4.5.1的项目使用带有以下参数的msbuild任务构建p,并且它正确地将代码发布到azure。一切都好!!

enter image description here

使用带有以下参数的msbuild任务正确构建.Net框架4.6.1的项目。

enter image description here

使用上述参数构建时,创建的包不会部署到azure。请参阅下面的日志。

enter image description here

请帮忙,真的很奇怪。我看到两个web api解决方案之间的区别仅在于.Net框架版本。

azure visual-studio-2015 msbuild tfsbuild azure-pipelines
2个回答
0
投票

首先建议您手动使用msbuild.exe命令进行发布。这将缩小与TFS方面有关的问题。

还要将构建代理上的Azure SDK更新到最新版本(Azure SDK for .NET 3.0)。

尝试强制MSBuild参数中的“PublishProfileRootFolder”参数。详情请参考这个问题:MsBuild not finding publish profile


0
投票

使用wpp文件来xml查看你的发布设置,这将在msbuild的运行时生成一个发布配置文件。使用xml片段下方创建wpp文件。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 

  <!--
  When using this file you must supply /p:PublishSettingsFile as a parameter and /p:DeployOnBuild=true
  -->  
  <PropertyGroup Condition=" Exists('$(PublishSettingsFile)')">
    <!-- These must be declared outside of a Target because they impact the Import Project flow -->
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <DeployTarget>WebPublish</DeployTarget>

    <PipelineDependsOn>
      GetPublishPropertiesFromPublishSettings;
      $(PipelineDependsOn);
    </PipelineDependsOn>
  </PropertyGroup>

  <Target Name="GetPublishPropertiesFromPublishSettings" BeforeTargets="Build" Condition=" Exists('$(PublishSettingsFile)')">
    <PropertyGroup>
      <_BaseQuery>/publishData/publishProfile[@publishMethod='MSDeploy'][1]/</_BaseQuery>
      <!-- This value is not in the .publishSettings file and needs to be specified, it can be overridden with a cmd line parameter -->
      <!-- If you are using the Remote Agent then specify this as RemoteAgent -->
      <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    </PropertyGroup>

    <ItemGroup>
      <_MSDeployXPath Include="WebPublishMethod">
        <Query>$(_BaseQuery)@publishMethod</Query>
      </_MSDeployXPath>

      <_MSDeployXPath Include="MSDeployServiceURL">
        <Query>$(_BaseQuery)@publishUrl</Query>
      </_MSDeployXPath>

      <_MSDeployXPath Include="SiteUrlToLaunchAfterPublish">
        <Query>$(_BaseQuery)@destinationAppUrl</Query>
      </_MSDeployXPath>

      <_MSDeployXPath Include="DeployIisAppPath">
        <Query>$(_BaseQuery)@msdeploySite</Query>
      </_MSDeployXPath>

      <_MSDeployXPath Include="UserName">
        <Query>$(_BaseQuery)@userName</Query>
      </_MSDeployXPath>

      <_MSDeployXPath Include="Password">
        <Query>$(_BaseQuery)@userPWD</Query>
      </_MSDeployXPath>
    </ItemGroup>

    <XmlPeek XmlInputPath="$(PublishSettingsFile)"
             Query="%(_MSDeployXPath.Query)"
             Condition=" Exists('$(PublishSettingsFile)')">
      <Output TaskParameter="Result" PropertyName="%(_MSDeployXPath.Identity)"/>
    </XmlPeek>
  </Target>
</Project>

使用上面的xml代码片段创建一个wpp文件,并将它放在csproj所在的同一项目中,或者如果要将wpp放在csproj文件夹之外以便在多个项目中重复使用,则需要添加/ p:WebPublishPipelineCustomizeTargetFile =

msbuild.exe MyProject /p:WebPublishPipelineCustomizeTargetFile=<path-to.targets-file>  /p:VisualStudioVersion=11.0 /p:DeployOnBuild=true /p:PublishSettingsFile=<path-to-.publishsettings> 

您可以在@ http://sedodream.com/2013/06/05/HowToPublishAVSWebProjectWithAPublishSettingsFile.aspx上找到有关实现的更多详细信息

© www.soinside.com 2019 - 2024. All rights reserved.