premake / premake/premake-core

Add support for `ExcludeAssets` tag on NuGet packages

Open
#2,425 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
3.6k
Forks
654
Avg merge
1d 1h
Merged PRs (30d)
13

Description

What problem will this solve?
Using MSBuild from C# requires referencing some assemblies whose dependencies are only required at build time. https://learn.microsoft.com/en-us/visualstudio/msbuild/find-and-use-msbuild-versions?view=vs-2022 states that you should add ExcludeAssets="runtime" to achieve this -- which (to my knowledge) is currently not possible within premake.

What might be a solution?
A potential avenue to adding this without needing to change NuGet package syntax would be to add some premake specific features to the NuGet package string:

nuget
{
    "Bar.Foo:1.0.0!ExcludeRuntime"
}

Or alternatively a secondary NuGet package API with more control:

nuget_new
{
    BarFoo = {
        Name = "Bar.Foo",
        Version = "1.0.0",
        ExcludeAssets = "runtime"
    }
}

I appreciate these are not necessarily the cleanest solutions -- they're just what came to mind given NuGet packages already have an interface being used in existing scripts which would break if it were changed.

What other alternatives have you already considered?
I suspect there may be a way to declare a NuGet package exclusively through vsprops but I am not an MSBuild expert and could not find a way to achieve this.

Anything else we should know?
N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing NuGet package string handling and the vsprops/MSBuild path mentioned in the issue. Determine how ExcludeAssets="runtime" should be represented without breaking existing package syntax, then verify that generated project metadata applies the requested setting.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.