question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dotnet publish => The 'Publish' target is not supported without specifying a target framework

See original GitHub issue

Steps 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:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
peterhuenecommented, Oct 16, 2018

@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 to dotnet publish. However, passing --framework netstandard2.0 to dotnet publish will get the library to publish successfully, but it will also prevent the console app from publishing since netstandard2.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, use dotnet publish to publish the console project:

cd Console
dotnet publish -c Release

This should publish the console application with the library dependency without errors.

10reactions
StefanBertelscommented, Feb 12, 2020

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>.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The 'Publish' target is not supported without specifying a ...
The current project targets multiple frameworks, please specify the framework for the published application.
Read more >
.NET Core: 'Publish' target is not supported - Damir Dobric ...
The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, please specify ...
Read more >
dotnet publish command - .NET CLI
dotnet publish - Publishes the application and its dependencies to a folder ... You must specify the target framework in the project file....
Read more >
Asp.net-core – The 'Publish' target is not supported without ...
Using Visual Studio 2017, I created an ASP.NET Core site using .NET Framework. (I do not have a project.json , I have a...
Read more >
dotnet publish Release fails (for server side project) #7965
NET.Sdk.CrossTargeting.targets(27,5): error : The 'Publish' target is not supported without specifying a target framework.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found