.NET Core MSBuild should not generate an empty assembly when building a meta-package project
See original GitHub issueI have a .NET Core meta-package project defined in project.json
. It contains no code but just references to a few other sub-projects and some packages. This meta-package project exists for 2 purposes:
- A NuGet meta-package can be produced that references to the NuGet packages of those sub-projects.
- The top-level project can reference only to this meta-package project to chain the dependency to those sub-projects.
This works fine with project.json
– when building the meta-package project, all referenced sub-projects get built and the meta-package project itself doesn’t produce anything.
Now with .NET Core SDK 1.0, I’m migrating from project.json
to .csproj
via dotnet migrate
, and I find the behavior has changed – building the meta-package project still get the referenced sub-projects built, but itself starts to produce an empty assembly.
This causes an empty meta-package.dll
to appear in the publish folder of the top-level project, and I cannot simply remove it with an after-build target because it’s also recorded in the generated .deps.json
file, which makes it part of the TPA (trusted platform assemblies). So simply removing the empty assembly will cause the application to crash at startup.
Note that I have set <IncludeBuildOutput>false</IncludeBuildOutput>
in the meta-package project file. It does help to make the empty assembly not included in the NuGet package produced out of the meta-package project, but the empty assembly still gets produced, and that causes the empty assembly to be published and put in the deps.json
file when building the top-level project.
The project.json
file and the corresponding .csproj
file are attached. It’s part of the powershell core project, and you can see the whole project at https://github.com/PowerShell/PowerShell/tree/master/src.
The Microsoft.PowerShell.SDK
meta-package project is referenced by powershell-unix\project.json
, powershell-win-core\project.json
and powershell-win-full\project.json
.
project.json.txt Microsoft.PowerShell.SDK.csproj.txt
/cc: @eerhardt
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:14 (7 by maintainers)
I don’t think it is possible. I think we probably would need to introduce a feature of some kind to support that.
Note, you can accomplish this in the project by setting the following properties:
Then you can just run the
Pack
target on that project, which can be set to the default target at the top:Now when you call MSBuild on that project, it will pack the nuget package, but you won’t get an empty assembly built or included in the package.