I have a simple prebuild target in a dependent project (called DAL):
<Target Name="PreBuild" BeforeTargets="Build">
<Message Text="RuntimeIdentifier value is: $(RuntimeIdentifier)" Importance="high" />
</Target>
When I build DAL, everything works as expected:
Command: dotnet build DAL\DAL.csproj --runtime linux-x64
Output: RuntimeIdentifier value is: linux-x64
But when I build the project that references DAL, the value for RuntimeIdentifier
disappears:
Command: dotnet build Transformer\Transformer.csproj --runtime linux-x64
Output: RuntimeIdentifier value is:
I added the --verbosity d
switch to the build command, and I noticed this:
Removing Properties for project "..\DAL\DAL.csproj":
TargetFramework
RuntimeIdentifier
Why is msbuild doing this and how can I pass the RuntimeIdentifier information to the DAL project when building/publishing the main project?
.NET Core SDK version: 3.1.402
, all projets target .NET Core 3.1
Thanks!
UPDATE: I added the following element to my csproj files:
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
Now the output is:
Determining projects to restore...
All projects are up-to-date for restore.
DAL -> C:\Source\...\DAL\bin\Debug\netcoreapp3.1\linux-x64\DAL.dll
RuntimeIdentifier value is: linux-x64
DAL -> C:\Source\...\DAL\bin\Debug\netcoreapp3.1\DAL.dll
RuntimeIdentifier value is:
Core -> C:\Source\...\Core\bin\Debug\netcoreapp3.1\Core.dll
Transformer -> C:\Source\...\Transformer\bin\Debug\netcoreapp3.1\linux-x64\Transformer.dll
It seems like the workaround is to set the RuntimeIdentifiers
element, is this by design?