10000 dotnet publish does not respect target framework from publish profile · Issue #11474 · dotnet/sdk · GitHub
[go: up one dir, main page]

Skip to content
dotnet publish does not respect target framework from publish profile #11474
Open
@holc-tkomp

Description

@holc-tkomp

Description

Running dotnet publish -p:PublishProfile=Anything.pubxml ignores the fact that the TargetFramework is specified within given .pubxml file and informs you (displays error) that you must specify the framework manually.

Current behavior

Error is displayed and publish process is stopped

The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, please specify the framework for the published application.

Expected behavior

TargetFramework should be retrieved from the .pubxml file.

Steps to reproduce

  1. dotnet new console.
  2. In .csproj set TargetFrameworks to netcoreapp2.1;netcoreapp3.1.
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
    <RootNamespace>dotnet_publish_issue</RootNamespace>
  </PropertyGroup>
</Project>
  1. Open up with VS, create any folder publish profile for netcoreapp2.1. Created profile should look like this
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishProtocol>FileSystem</PublishProtocol>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <PublishDir>bin\Release\netcoreapp2.1\publish\</PublishDir>
  </PropertyGroup>
</Project>
  1. Executing dotnet publish -p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml results in error:
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.CrossTargeting.targets(27,5): error : The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, please specify the framework for the published application. [C:\dotnet publish issue\dotnet publish issue.csproj]

Executing dotnet publish -p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml -f:netcoreapp2.1 works fine, but why does .pubxml's <TargetFramework> node is ignored?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CLIPublishVsBuildcli-uxIssues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0