dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.06k forks source link

Publishing classlib silently ignores --self-contained #2549

Open vitek-karas opened 5 years ago

vitek-karas commented 5 years ago

Repro (.NET SDK 2.1.500):

mkdir cl1
cd cl1
dotnet new classlib
dotnet publish --self-contained

The --self-contained parameter does nothing for a publish on a classlib. This issue is not about the fact that SDK doesn't support self-contained class libs. This is about the fact that asking for self-contained doesn't fail. SDK will simply ignore the parameter.

It's probably not OK to start failing, but maybe issuing a warning about usage of a parameter which will not have any effect should be possible.

livarcocc commented 5 years ago

@peterhuene this is around the same area that you are looking at. Could you take a look/comment?

peterhuene commented 5 years ago

I think a warning with SelfContained set for a lib project would make sense. I have concerns over project references, though. Right now the global SelfContained property is propagating to project references, which would cause a warning from every referenced lib project from an exe project that one would want to publish in a self-contained manner.

There's other issues to address in this area, so I think it might be worth doing.

vitek-karas commented 5 years ago

Please also consider currently broken behavior:

dotnet new classlib -f netcoreapp2.1
dotnet publish --self-contained -r win-x64

Will actually produce what looks like a self-contained app (with the copy of the runtime and so on). It will also include apphost.exe (always with that name), which fails to launch with a rather weird error message. (SDK copied over the original prebuilt apphost.exe but didn't customize it in any way).