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

查看:521
本文介绍了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>bin\Release\netcoreapp3.1\publish\</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>
</Project>

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

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

更新#1

Structure
src\MyProject\MyProject.csproj
src\MyProject.Utils\ect.Utils.csproj
src\MyProject.Web\MyProject.Web.csproj
src\MyProject.Web.sln

和pubxml的路径

src\MyProject.Web\Properties\PublishProfiles\ProductionPublish.pubxml

推荐答案

您需要使用以下命令:

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

  • 它是build,而不是publish.

    • It's build, not 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=Properties\PublishProfiles\FolderProfile.pubxml

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

      请参见 查看全文

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