Skip to content

Error with Exe project dependency when setting -r in dotnet publish #47651

Open
@freddyrios

Description

@freddyrios

With regular dependencies, running dotnet publish works: dotnet publish LoopControl -c Release -r [targetrid] --self-contained -p:PublishSingleFile=true

However, when adding a dependency to a project that has its output set to Exe, the command fails with this message :

[pathtodotnetsdk]\9.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1047: Assets file '[pathtodependency]\obj\project.assets.json' doesn't have a target for 'net8.0/[host-rid]'. Ensure that restore has run and that you have included 'net8.0' in the TargetFrameworks for your project. You may also need to include '[host-rid]' in your project's RuntimeIdentifiers.

Workaround: adding this to the dotnet publish line: -p:RuntimeIdentifiers=[targetrid]

That makes it work, but it should not be needed when one is already specifying the target via -r. It is of course far from obvious, so took a while to find the workaround.

Metadata

Metadata

Assignees

Labels

Area-NetSDKmulti-RID-publishingIssues related to the lack of multi-RID publishing semantics in the SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions