Dotnet publish => The 'Publish' target is not supported without specifying a target framework
See original GitHub issueSteps to reproduce
When I use command:
dotnet publish /p:Configuration=Release
I get error:
C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\buildCrossTargeting\Microsoft.NET.Sdk.targets(31,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.
I try execute with params:
--runtime="ubuntu.16.10-x64"
or
-f="netcoreapp2.0"
and not working.
Expected behavior
Actual behavior
Environment data
dotnet --info
output:
`Product Information:
Version: 2.1.4
Commit SHA-1 hash: 5e8add2190
Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.4\
Microsoft .NET Core Shared Framework Host
Version : 2.0.5 Build : 17373eb129b3b05aa18ece963f8795d65ef8ea54`
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
@mszymankiewicz unfortunately this another instance of publishing at the solution level not working well. What’s happening here is that it’s publishing every project in the solution independently. When it tries to publish the library project, it fails because the project targets multiple frameworks and publishing only works for a single framework target at a time.
Thus, it requires that a
--framework
option be specified todotnet publish
. However, passing--framework netstandard2.0
todotnet publish
will get the library to publish successfully, but it will also prevent the console app from publishing sincenetstandard2.0
isn’t a supported target of the console project.We do not recommend using
dotnet publish
to publish solutions. Instead, publish the root projects (projects that are not referenced by other projects). In this example, usedotnet publish
to publish the console project:This should publish the console application with the library dependency without errors.
I have a similiar problem (solution with two projects, one has multiple target frameworks). I want to call “dotnet publish” on solution level without specifying a framework. The multi-target project should be skipped. I set
<IsPublishable>false</IsPublishable>
in the csproj of the multi-target project but this was ignored. This attribute should be checked before checking<TargetFrameworks>
.