2

Essientially I need to say:

<ProjectRefererence Target="../tool/tool.csproj">
    <RID>any</RID>
</ProjectReference>

where I need to specifically reference the "any" rid that is produced by dotnet build without the -r. Trying to reference a specific rid is guaranteed to not work. The default behavior is to build the dependent dll for the specific rid the current project is being built with. This will not work. The output assembly must be portable across architectures as it is loaded by reflection on potentially a different architecture it originated from.

Salomon Zhang
  • 1,553
  • 3
  • 23
  • 41
Joshua
  • 40,822
  • 8
  • 72
  • 132

1 Answers1

3

You can change the project reference to include a global property that will override the defined value in the project (global properties from a command line or project reference will override properties statically defined in a project file):

<ItemGroup>
  <ProjectReference Include="..\ridspecificproj\ridspecificproj.csproj" Properties="RuntimeIdentifier=" />
</ItemGroup>

This will set RuntimeIdentifier to empty and the project will be built RID-independent.

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • Intellisense doesn't recognize a Properties attribute here and the only reference I can find for a Properties attribute on ProjectReference is this answer. – Joshua Dec 05 '17 at 17:18
  • 1
    Yeah this is poorly documented but the way msbuild and its "common targets" work. There's also a `GlobalPropertiesToRemove` metadata item that is respected and helpful if you don't want to pass any commandline arguments to referenced projects. – Martin Ullrich Dec 05 '17 at 18:27
  • 1
    The code is here: https://github.com/Microsoft/msbuild/blob/f0ee71c0d782cdf83693d1d14171800ec16650c1/src/Tasks/MSBuild.cs#L706-L708 – Martin Ullrich Dec 05 '17 at 18:29