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 issueSteps to reproduce
- Create 3 projects
- dotnet new classlib
- dotnet new nunit
- dotnet new console
- Link all 3 projects into a .sln file (t.sln)
- Both nunit and console project reference classlib as project reference
- 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:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
You can add
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 toFalse
and then adding it withTrue
to all your “entry point” apps)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.