Open ltrzesniewski opened 3 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
I've noticed the same problem.
It seems instead of specifying SkipGetTargetFrameworkProperties in A.csproj another workaround is to specify RuntimeIdentifiers in B.csproj. Something like this <RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
.
I don't really understand why, but when RuntimeIdentifiers is specified the runtime identifier is forwarded to B.csproj when doing a publish on A.csproj.
It would be nice if someone with a better understanding could elaborate on this.
Same, it caused inconvenience when publishing a project that references many other projects.
If you don't want to modify project files like @deng0 mentions, you need to build all the depended projects manually with -r
before publishing with --no-build
.
I noticed that the SkipGetTargetFrameworkProperties
workaround doesn't work with projects that need to generate a publish-specific deps.json file, as of the SDK 5.0.400-preview.21277.10.
In my case, this situation happened because of a PackageReference
with PrivateAssets="all"
.
Here's a different workaround, in case it helps anyone:
<Target Name="AddReferencedExeProjectForPublish" BeforeTargets="CopyFilesToPublishDirectory">
<MSBuild Projects="..\B\B.csproj" Targets="Publish" Properties="PublishDir=$([System.IO.Path]::GetFullPath($(PublishDir)))" BuildInParallel="$(BuildInParallel)" />
</Target>
It essentially publishes B
to the same output path when you want to publish A
. Not pretty, but it works.
This may be the same as or related to #21677
This is a follow-up to #1675 and #14488. Tested with the SDK v5.0.200.
If you have a project A that references a project B, and both are of the exe output type, then publishing A with a runtime identifier will generate a self-contained A, but a framework-dependent B.
Here's a simple repro:
A.deps.json
will have the.NETCoreApp,Version=v5.0/win-x64
runtime target, andB.deps.json
will have.NETCoreApp,Version=v5.0
.Workaround:
If you change the project reference to the following:
Then B will be published in self-contained mode as expected.
/cc @dsplaisted