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.
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 (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) 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/
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
Publishing for specific TFMs for solutions is a known issue that we have had on the CLI. I would suggest publishing your project(s) directly when specifying a TFM. The right things should happen then.
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.
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)
@dasMulli thanks for the suggestion!
The reason I need to target specific framework is to be able to publish both netcoreapp and netframework projects but as separate CI builds, so setting IsPublishable is not really a way forward, as it will break the other build. The only good alternative to consider is to split the repository, so I just added my 2 cents to this issue because of the current situation I have, and if the dotnet tool could handle such a scenario, it would be really convenient for me.
Hi! Take a look at the workarounds i posted here - https://github.com/dotnet/sdk/issues/9324#issuecomment-665519591