dotnet 发布配置文件忽略 pubxml 文件 [英] dotnet publish profile ignores pubxml file

查看:53
本文介绍了dotnet 发布配置文件忽略 pubxml 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下通过 Visual Studio 2019 创建的 pubxml 文件:

I have the following pubxml file which I created via Visual Studio 2019:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <ProjectGuid>143a6329-27d9-474e-9521-835be634c293</ProjectGuid>
    <SelfContained>true</SelfContained>
    <publishUrl>binRelease
etcoreapp3.1publish</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>
</Project>

当我运行 dotnet.exe publish srcMyProject.Web.sln -p:PublishProfile=PropertiesPublishProfilesProductionPublish.pubxml Release 不包含任何内容并且发布发生在 Debug 文件夹(调试版本).为什么会发生这种情况而忽略 pubxml?

When I run dotnet.exe publish srcMyProject.Web.sln -p:PublishProfile=PropertiesPublishProfilesProductionPublish.pubxml Release does not contain anything and publish happens on Debug folder (debug build). Whys does this happens and pubxml is ignored?

更新 #1

Structure
srcMyProjectMyProject.csproj
srcMyProject.Utilsect.Utils.csproj
srcMyProject.WebMyProject.Web.csproj
srcMyProject.Web.sln

和pubxml的路径

srcMyProject.WebPropertiesPublishProfilesProductionPublish.pubxml

推荐答案

您需要使用以下命令:

dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile

  • build,而不是publish.

    即使我的 FolderProfile 的配置设置为 Release,我也不得不包括 -c Release 因为否则依赖项目被构建带有调试配置.

    Even if my FolderProfile's configuration is set to Release, I had to include -c Release because otherwise dependent projects were built with debug configuration.

    如果在没有 /p:DeployOnBuild=true 的情况下调用,文件不会复制到目标位置.

    Files not copied to target location if called without /p:DeployOnBuild=true.

    只要名称 FolderProfile - 没有扩展名 - 就足够了
    配置文件.或者你可以给路径
    /p:PublishProfile=PropertiesPublishProfilesFolderProfile.pubxml

    Just the name FolderProfile -without extension- is enough for the
    profile file. Or you can give the path
    /p:PublishProfile=PropertiesPublishProfilesFolderProfile.pubxml

    参见 Microsoft Docs 中的文件夹发布示例.

    这篇关于dotnet 发布配置文件忽略 pubxml 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆