I have a package which should only be a compile-time dependency, i.e. included in the build but not part of output. Like "CopyLocal=false" works in non-sdk projects.
I tried <ExcludeAssets>runtime</ExcludeAssets>
on PackageReference
which sort of works but not consistently. Sometimes the dependency is also excluded from the build. (reopening the solution fixes it sometimes. It is all very random)
So I have 2 questions:
- Is excluding "runtime" supposed to also exclude it from build or is that a bug?
- Is there another way to include a dependency in the build but exclude it from runtime.
Background:
I have two types of dependencies where I need this functionality. One is a licensed product where a "generic" version of the assembly is used for the build. Similar to reference assemblies i Visual Studio. The real assembly is available in the production environment.
The second one is an assembly containing only constants. It is not needed at runtime since it is not used.
Excluding the constant-only assembly is just cosmetic but shipping the "generic" assemblies causes problems on e.g. updates where they can overwrite the real ones.