ProjectReference Platform Negotiation - Platform Not Set #6871
-
I'm trying to make use of the new ProjectReference SetPlatform Negotiation feature. After performing all of the documented steps to enable the feature, I could not get a simplistic two project (non-SDK style) build to work correctly. In this case, NetFx.Library2 (x86/x64) referenced NetFx.Library1 (AnyCPU). When attempting to build, it would result with the following error:
After exploring the logs and associated code changes for the feature, I could see that Is there any reason why Logs: |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
thanks for filing this! Here's my own analysis (which agrees with yours): Legacy style projects expect to be built with a <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x64\</OutputPath> <======== legacy projects set outputpath based on config|platform
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup> Because x64 isn't a "previously agreed upon" platform for your referenced project, outputpath isn't being defined and thus we're hitting that issue. Presumably sdk style projects define this themselves or use the defaults we supply in common.currentversion.targets. Some temporary workarounds would be:
Part of the issue here is a distinction between of course there are many solutions we can consider for MSBuild. To brainstorm some, we could:
<PropertyGroup>
<!-- Example, AnyCPU -->
<_OriginalPlatform>$(Platform)</_OriginalPlatform>
<!-- Example, Debug -->
<_OriginalConfiguration>$(Configuration)</_OriginalConfiguration>
<!-- Check whether OutputPath was specified for valid Configuration/Platform combination -->
<_OutputPathWasMissing Condition="'$(_OriginalPlatform)' != '' and '$(_OriginalConfiguration)' != '' and '$(OutputPath)' == ''">true</_OutputPathWasMissing>
<!-- Check whether BaseOutputPath was specified -->
<BaseOutputPathWasSpecified Condition="'$(BaseOutputPath)' != ''">true</BaseOutputPathWasSpecified>
</PropertyGroup> We can add something like:
^ I'm leaning toward this. It also reduces the separation between the two properties. @rainersigwald thoughts? @AArnott Do you expect to see the VS migration running into this? |
Beta Was this translation helpful? Give feedback.
-
Investigation notes:
This answers how What about sdk-style projects? I found this in Microsoft.NET.Sdk.props
It looks like The following snippet looks to answer my question. It defaults <!-- Determine PlatformTarget (if not already set) from runtime identifier. -->
<Choose>
<When Condition="'$(PlatformTarget)' != '' or '$(RuntimeIdentifier)' == ''" />
<When Condition="$(RuntimeIdentifier.EndsWith('-x86')) or $(RuntimeIdentifier.Contains('-x86-'))">
<PropertyGroup>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-x64')) or $(RuntimeIdentifier.Contains('-x64-'))">
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-arm')) or $(RuntimeIdentifier.Contains('-arm-'))">
<PropertyGroup>
<PlatformTarget>arm</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-arm64')) or $(RuntimeIdentifier.Contains('-arm64-'))">
<PropertyGroup>
<PlatformTarget>arm64</PlatformTarget>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Otherwise>
</Choose> And to confirm order of imports, My last question at this point: If Regardless, I think this answers my question for sdk-style projects: Thanks for coming to my TED talk :) |
Beta Was this translation helpful? Give feedback.
-
@jhennessey can you confirm that adding |
Beta Was this translation helpful? Give feedback.
-
This problem is being addressed by issue #6887. See discussion above for a work-around in the meantime. |
Beta Was this translation helpful? Give feedback.
This problem is being addressed by issue #6887. See discussion above for a work-around in the meantime.