NuGet product used (VS UI | Package Manager Console | dotnet.exe):
dotnet.exe --version (if appropriate): 3.0.100-preview3-010431
VS version (if appropriate): 16.0.0 Preview 4.1 SVC1 / 15.9.8
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2;net472</TargetFrameworks>
<Platforms>x64;x86</Platforms>
</PropertyGroup>
<!--<ItemGroup Condition="'$(Platform)' == 'x64'">-->
<!--<ItemGroup Condition="'$(Platform)' == 'x64' AND ('$(TargetFramework)' == 'netcoreapp3.0' Or '$(TargetFramework)' == 'netcoreapp2.2')">-->
<ItemGroup Condition="'$(TargetFramework)' != 'net472' AND '$(Platform)' != 'x86'">
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27413-02" />
</ItemGroup>
</Project>
Try to publish x86:
dotnet publish -c Release -f netcoreapp3.0 -r win-x86
Error:
C:\Users\Me.nuget\packages\microsoft.dotnet.ilcompiler\1.0.0-alpha-27413-02\build\Microsoft.NETCore.Native.Publish.targets(65,5): error : win-x86 not supported yet. https://github.com/dotnet/corert/issues/4589 [C:\Development\Test\Test.csproj]
The commented out conditions all don't work. Either they result in both x86 and x64 builds trying to use the referenced package or neither of them using the referenced package. Either way it seems impossible to specify a PackageReference specific to the platform. Also tried adding the condition on the PackageReference rather than ItemGroup with the same results.
To summarize, even with the condition "false", the package will be imported.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2;net472</TargetFrameworks>
<Platforms>x64;x86</Platforms>
</PropertyGroup>
<ItemGroup Condition="false">
<PackageReference Include="MyPackage" Version="1.0.0" />
</ItemGroup>
</Project>
We found that we can work around this issue by putting the packagereference in a different file, and making the import of the file conditional.
Separate file: packagerefs.targets
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="MyPackage" Version="1.0.0" />
</ItemGroup>
</Project>
Project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2;net472</TargetFrameworks>
<Platforms>x64;x86</Platforms>
</PropertyGroup>
<Import Project="packagerefs.targets" Condition="false" />
</Project>
Closing this as duplicate of https://github.com/NuGet/Home/issues/5895.
TargetFramework is the only project configuration pivot support.
Platform/Architecture/Configuration and the likes are not supported.