【问题标题】:msbuild arguments failing for new website新网站的 msbuild 参数失败
【发布时间】:2020-10-09 16:10:57
【问题描述】:

我遇到了一个我无法解决的 msbuild 问题。

大约 15 个月前,我继承了一个包含大约 6 个网站的 asp.net mvc Web 解决方案。大约一年来,我一直在使用 azure 构建管道构建所有这些站点,并使用 azure 部署管道进行部署。

我们一直在使用这些 msbuild 参数来构建解决方案中的所有站点。

/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:PublishBaseUrl="$(build.artifactstagingdirectory)\\" /p:DeployDefaultTarget=WebPublish

这总是工作得很好,并产生了一个非常干净的文件夹结构,我们可以轻松部署。

但是,我最近在解决方案中添加了第 7 个站点,这样做后,我现在在尝试使用这些参数进行构建时收到以下错误。

C:\source\myproject.csproj" (default target) (17) ->
(WebFileSystemPublish target) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\Web\Deploy\Microsoft.Web.Publishing.Deploy.FileSyst
em.targets(55,5): error : This specific WebPublishMethod(FileSystem) is not yet supported on msbuild command line.  Please use Visual Studio to publish.

error : Target WebFileSystemPublish Failed

该错误仅发生在刚刚添加到解决方案中的全新项目上。我已尝试在项目文件中找到可能导致此问题的设置,但目前我还没有提出任何建议。

更新: 分析 msbuild 日志显示以下错误仅发生在添加到解决方案中的新 csproj 文件上,表明“默认目标”存在问题

【问题讨论】:

    标签: asp.net-mvc azure-devops msbuild


    【解决方案1】:

    我们不确定是什么导致了上述 msbuild 错误。我们知道的主要变化是从 .net 框架 4.5 到 4.7.2 的修改

    经过大量工作和研究后,该问题的解决方案是在 azure devops 中使用以下 msbuild 参数:

    /p:WebPublishMethod=FileSystem /p:publishbaseurl="$(build.artifactstagingdirectory)\" /p:DeployOnbuild=true /p:DeployDefaultTarget=WebPublish

    并将此文件添加到我们解决方案中的每个项目文件夹中。 'directory.build.props'

    里面有下面的xml

    <Project>
      <PropertyGroup>
        <PublishUrl Condition="'$(PublishBaseUrl)' != '' and '$(PublishUrl)' == ''">$(PublishBaseUrl)\$(MSBuildProjectName)\</PublishUrl>
      </PropertyGroup>
    </Project>
    

    这立即让我们的构建开始成功地为解决方案中的每个项目创建一个文件夹。

    【讨论】:

    • 嗨@Matt,感谢您的分享,您可以将其标记为答案,这样可以帮助遇到相同问题的其他社区成员,我们可以存档此线程,谢谢。
    猜你喜欢
    • 2018-10-18
    • 2012-03-25
    • 1970-01-01
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多