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 -f netcoreapp2.2 mysolution.sln should publish netcoreapp2.2 targets in solution but not generate errors for .netstandard2.2 projects in solution

See original GitHub issue

Steps to reproduce

  1. Create 3 projects
    • dotnet new classlib
    • dotnet new nunit
    • dotnet new console
  2. Link all 3 projects into a .sln file (t.sln)
  3. Both nunit and console project reference classlib as project reference
  4. run: dotnet publish -f netcoreapp2.2 t.sln

Expected behavior

No errors, Netcore projects (nunit, console) publish to the publish folder for both projects. Class library does not publish, because -f netcoreapp2.2 was selected, not netstandard2.2. Also – dotnet publish -f netstandard t.sln publishes only the class lib with its dependencies. No empty classlib/bin/Debug/netcoreapp2.2 folder present During the build, a message is shown that project classlib is not being published, because it does not match the requested target framework type.

Actual behavior

Error message is shown in RED. Note that both netcore projects do publish correctly with the dependencies present. Empty ./classlib/bin/Debug/netcoreapp2.2 is created.

Microsoft ® Build Engine version 15.9.20+g88f5fadfbe for .NET Core Copyright © Microsoft Corporation. All rights reserved.

Restore completed in 49.54 ms for /Users/Friedrich/tmp/t/unittest/unittest.csproj. Restore completed in 49.09 ms for /Users/Friedrich/tmp/t/netcore/netcore.csproj. Restore completed in 49.09 ms for /Users/Friedrich/tmp/t/classlib/classlib.csproj. /usr/local/share/dotnet/sdk/2.2.105/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(208,5): error NETSDK1005: Assets file ‘/Users/Friedrich/tmp/t/classlib/obj/project.assets.json’ doesn’t have a target for ‘.NETCoreApp,Version=v2.2’. Ensure that restore has run and that you have included ‘netcoreapp2.2’ in the TargetFrameworks for your project. [/Users/Friedrich/tmp/t/classlib/classlib.csproj] classlib -> /Users/Friedrich/tmp/t/classlib/bin/Debug/netstandard2.0/classlib.dll netcore -> /Users/Friedrich/tmp/t/netcore/bin/Debug/netcoreapp2.2/netcore.dll netcore -> /Users/Friedrich/tmp/t/netcore/bin/Debug/netcoreapp2.2/publish/ unittest -> /Users/Friedrich/tmp/t/unittest/bin/Debug/netcoreapp2.2/unittest.dll unittest -> /Users/Friedrich/tmp/t/unittest/bin/Debug/netcoreapp2.2/publish/

Environment data

dotnet --info output: .NET Core SDK (reflecting any global.json): Version: 2.2.105 Commit: 7cecb35b92

Runtime Environment: OS Name: Mac OS X OS Version: 10.14 OS Platform: Darwin RID: osx.10.14-x64 Base Path: /usr/local/share/dotnet/sdk/2.2.105/

Host (useful for support): Version: 2.2.3 Commit: 6b8ad509b6

.NET Core SDKs installed: 1.0.0-preview2-003148 [/usr/local/share/dotnet/sdk] 1.0.0-preview2-1-003177 [/usr/local/share/dotnet/sdk] 1.0.0-preview3-004056 [/usr/local/share/dotnet/sdk] 1.0.0-preview4-004233 [/usr/local/share/dotnet/sdk] 1.0.1 [/usr/local/share/dotnet/sdk] 2.0.0-preview1-005977 [/usr/local/share/dotnet/sdk] 2.0.0-preview2-006497 [/usr/local/share/dotnet/sdk] 2.0.0 [/usr/local/share/dotnet/sdk] 2.1.4 [/usr/local/share/dotnet/sdk] 2.1.101 [/usr/local/share/dotnet/sdk] 2.1.302 [/usr/local/share/dotnet/sdk] 2.2.103 [/usr/local/share/dotnet/sdk] 2.2.105 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0-preview1-002111-00 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0-preview2-25407-01 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dasMullicommented, Feb 12, 2020

You can add

  <PropertyGroup>
    <IsPublishable>False</IsPublishable>
  </PropertyGroup>

To all these projects you don’t want to have published and should then be able to call dotnet publish -f .. on a solution. (or do it the other way round by creating a Directory.Build.props file setting it to False and then adding it with True to all your “entry point” apps)

1reaction
artazarcommented, Feb 12, 2020

Having the ability to skip netstandard targets, when you publish only netcoreapp framework, would come handy for automating builds. The need to specify a particular csproj file causes inconvenience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet publish -f netcoreapp2.0 mysolution.sln should ...
I have a solution comprised of multiple .net core C# projects, some commandline 'exe' netcoreapp2.0 targets, some classlib 'dll' netstandard2.0 targets.
Read more >
dotnet publish sln having projects with multiple target ...
With this command I have this error while building the project with double target framework. Here's the errors: C:\Program Files\dotnet\sdk\2.1.
Read more >
Publish .NET apps with the .NET CLI
This article demonstrates how you can publish your .NET application from the command line. .NET provides three ways to publish your ...
Read more >
dotnet publish command - .NET CLI
dotnet publish - Publishes the application and its dependencies to a folder for deployment to a hosting system.
Read more >
Dotnet build command. Docker. exe starts the CLI command exe
NET Core 2. dll after build to 32 bit (by publish or build). Right-click on the project node in Solution Explorer and select...
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