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.

.NET Core MSBuild should not generate an empty assembly when building a meta-package project

See original GitHub issue

I 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:

  1. A NuGet meta-package can be produced that references to the NuGet packages of those sub-projects.
  2. 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 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:open
  • Created 7 years ago
  • Reactions:3
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

nguerreracommented, Jul 15, 2019

I don’t think it is possible. I think we probably would need to introduce a feature of some kind to support that.

eerhardtcommented, Jul 12, 2019

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:

<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack">

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make .NET Core MSBuild to not generate an empty ...
I have a .NET Core meta-package project defined in project.json . It contains no code but just references to a few other sub-projects....
Read more >
Chapter 3. How to build with .NET Core - liveBook · Manning
When you add a dependency to a project file, that dependency can be a package, metapackage, or another project. A package is generally...
Read more >
Part 2 - Caveats of project.json to MSBuild conversion
This means you must upgrade to csproj to build .NET Core projects in VS 2017, and you must not upgrade to csproj if...
Read more >
Protocol Buffers/gRPC Integration Into .NET Build
cs files as temporary, this is ok, but when generating them for you, creating empty files is probably not. You need to tell...
Read more >
Create a NuGet package using MSBuild
A detailed guide to the process of designing and creating a NuGet package using MSBuild, including key decision points like files and ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found