Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use live runtime references for vcxproj #10028

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions eng/Tools.props

This file was deleted.

1 change: 1 addition & 0 deletions eng/WpfArcadeSdk/tools/RuntimeFrameworkReference.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- workaround for package downgrade in Microsoft.NetCore.Platforms -->
<PropertyGroup>
<DisableImplicitNETCorePlatformsReference>true</DisableImplicitNETCorePlatformsReference>
<EnableManagedPackageReferenceSupport>true</EnableManagedPackageReferenceSupport>
</PropertyGroup>

</Project>
65 changes: 1 addition & 64 deletions eng/WpfArcadeSdk/tools/RuntimeFrameworkReference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.Platforms"
Version="$(MicrosoftNETCorePlatformsVersion)"
Condition="'$(MSBuildProjectExtension)'!='.vcxproj'"/>

<AdditionalPackageReference Include="Microsoft.NETCore.Platforms"
Version="$(MicrosoftNETCorePlatformsVersion)"
Condition="'$(ManagedCxx)'=='true'"/>
Condition="'$(MSBuildProjectExtension)'!='.vcxproj' or '$(ManagedCxx)'=='true'"/>

<!--
Workaround - this should be removed when our tests are converted from Microsoft.NET.Sdk.WindowsDesktop => Microsoft.NET.Sdk
Expand Down Expand Up @@ -42,63 +38,4 @@
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true'" />
</ItemGroup>

<!-- These properties can be removed when vcxproj's NuGet support gets enabled. -->
<PropertyGroup>
<EnableTargetingPackDownload Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableTargetingPackDownload>
<EnableRuntimePackDownload Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableRuntimePackDownload>
<GenerateErrorForMissingTargetingPacks Condition="'$(EnableTargetingPackDownload)' == 'false'">false</GenerateErrorForMissingTargetingPacks>

<EnableAppHostPackDownload Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'">false</EnableAppHostPackDownload>
</PropertyGroup>

<!-- Update paths for resolved packs which is necessary when the packs couldn't be resolved.
This happens when package download is disabled and the package isn't available in the SDK's packs folder.
This entire target can be removed when vcxproj's NuGet support gets enabled. -->
<Target Name="UpdateOOBPacks"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<Error Text="'MicrosoftNETCoreAppRefVersion' is not set. Please set it to the version of the targeting pack you want to use." Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(MicrosoftNETCoreAppRefVersion)' == ''" />
<Error Text="'MicrosoftNETCoreAppRuntimewinx64Version' is not set. Please set it to the version of the runtime pack you want to use." Condition="('$(UseOOBNETCoreAppRuntimePack)' == 'true' or '$(UseOOBNETCoreAppAppHostPack)' == 'true') and '$(MicrosoftNETCoreAppRuntimewinx64Version)' == ''" />

<ResolvedTargetingPack Path="$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)"
NuGetPackageVersion="$(MicrosoftNETCoreAppRefVersion)"
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)"
Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false' and '%(ResolvedTargetingPack.RuntimeFrameworkName)' == 'Microsoft.NETCore.App'" />

<ResolvedRuntimePack PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.runtime.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
NuGetPackageVersion="$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false' and '%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
</ItemGroup>

<PropertyGroup>
<_ResolvedRuntimePackPath>@(ResolvedRuntimePack->WithMetadataValue('FrameworkName', 'Microsoft.NETCore.App')->Metadata('Path'))</_ResolvedRuntimePackPath>
</PropertyGroup>

<ItemGroup>
<ResolvedFrameworkReference Condition="'%(Identity)' == 'Microsoft.NETCore.App'">
<TargetingPackPath Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false'">$(NuGetPackageRoot)microsoft.netcore.app.ref\$(MicrosoftNETCoreAppRefVersion)</TargetingPackPath>
<TargetingPackVersion Condition="'$(UseOOBNETCoreAppTargetingPack)' == 'true' and '$(EnableTargetingPackDownload)' == 'false'">$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
<RuntimePackPath Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false'">$(_ResolvedRuntimePackPath)</RuntimePackPath>
<RuntimePackVersion Condition="'$(UseOOBNETCoreAppRuntimePack)' == 'true' and '$(EnableRuntimePackDownload)' == 'false'">$(MicrosoftNETCoreAppRuntimewinx64Version)</RuntimePackVersion>
</ResolvedFrameworkReference>

<ResolvedAppHostPack Path="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)\%(ResolvedAppHostPack.PathInPackage)"
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(EnableAppHostPackDownload)' == 'false'" />

<ResolvedIjwHostPack Path="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)\%(ResolvedIjwHostPack.PathInPackage)"
PackageDirectory="$(NuGetPackageRoot)microsoft.netcore.app.host.%(RuntimeIdentifier)\$(MicrosoftNETCoreAppRuntimewinx64Version)"
Condition="'$(UseOOBNETCoreAppAppHostPack)' == 'true' and '$(EnableAppHostPackDownload)' == 'false'" />
</ItemGroup>

<PropertyGroup Condition="'@(ResolvedAppHostPack)' != '' And '$(AppHostSourcePath)' == ''">
<AppHostSourcePath>@(ResolvedAppHostPack->'%(Path)')</AppHostSourcePath>
</PropertyGroup>

<PropertyGroup Condition="'@(ResolvedIjwHostPack)' != '' And '$(IjwHostSourcePath)' == ''">
<IjwHostSourcePath>@(ResolvedIjwHostPack->'%(Path)')</IjwHostSourcePath>
</PropertyGroup>
</Target>

</Project>
154 changes: 0 additions & 154 deletions eng/WpfArcadeSdk/tools/Wpf.Cpp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -276,160 +276,6 @@ using namespace System::Runtime::Versioning;
</ItemGroup>
</Target>


<PropertyGroup Condition="'$(ManagedCxx)'=='true'">
<ResolveReferencesDependsOn>
CppCliHelper;
$(ResolveReferencesDependsOn)
</ResolveReferencesDependsOn>
<EnsureWpfProjectReferenceDependsOn>
$(EnsureWpfProjectReferenceDependsOn);
CppCliHelper
</EnsureWpfProjectReferenceDependsOn>
</PropertyGroup>

<!--
Helper for building C++/CLI projects

C++/CLI doe not have Sdk support for build on .NET Core
We use existing support for C# to discover Nuget packages, and pass it along to
the C++ compiler.

A simple C# project is generated dynamically. It contains PackageReferences for common packages
that are used in WPF's C++/CLI projects. There are only two such projects - DirectWriteForwarder
and System.Printing - which makes it unnecessary to create a flexible and parametrized target. This
can remain a simple and one-size-fits-all target for now.

If additional Nuget references need to be discovered and passed along for builds (for existing, or new) of
C++/CLI projects, they just need to be added to the vcxproj project file like this:

<AdditionalPackageReference Include="Microsoft.Win32.Registry" Version="<version>" />
-->
<Target Name="CppCliHelper"
Returns="@(Reference)"
Condition="'$(ManagedCxx)' == 'true'">

<PropertyGroup>
<CppCliHelperProject>$(IntermediateOutputPath)CppCliSupport\CppClrSupport_$(MSBuildProjectName).csproj</CppCliHelperProject>
</PropertyGroup>

<ItemGroup>
<CppClrSupportProject Include="ProjectHeader">
<!--
In the CDATA section that follows,
%40 ~= @
%25 ~= %
%3B ~= ;
%24 ~= $
-->
<Text>
<![CDATA[
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="EnumerateAdditionalNugetReference">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Platforms>AnyCPU%3Bx64%3Barm64</Platforms>
</PropertyGroup>
]]>
</Text>
</CppClrSupportProject>


<CppClrSupportProject Include="ProjectBody">
<Text>
<![CDATA[


<Target Name="EnumerateAdditionalNugetReference"
BeforeTargets="_GenerateRestoreGraph"
Condition="'%24(AdditionalPackages)'!=''"
Returns="%40(PackageReference)">
<ItemGroup>
<_AdditionalPackages Remove="%40(_AdditionalPackages)" />
<_AdditionalPackages Include="%24(AdditionalPackages)" />

<PackageReference Include="%24([System.String]::Copy('%25(_AdditionalPackages.Identity)').Split('+')[0])"
Version="%24([System.String]::Copy('%25(_AdditionalPackages.Identity)').Split('+')[1])" />

<AdditionalNugetIds Remove="%40(AdditionalNugetIds)" />
<AdditionalNugetIds Include="%24([System.String]::Copy('%25(_AdditionalPackages.Identity)').Split('+')[0])" />
</ItemGroup>

<!--
Removing the Microsoft.NETCore.Platforms directly and then
adding it again to remove the duplicate reference.
-->
<ItemGroup>
<PackageReference Remove="Microsoft.NETCore.Platforms" />
<PackageReference Include="Microsoft.NETCore.Platforms"
Version="$(MicrosoftNETCorePlatformsVersion)" />
</ItemGroup>
</Target>

<Target
Name="IdentifyNugetReferences"
AfterTargets="ResolveAssemblyReferences"
Returns="%40(NugetReferencesForCppCli)">

<!-- Save Microsoft.NETCore.App assemblies and return them -->
<ItemGroup>
<NugetReferencesForCppCli Remove="%40(NugetReferencesForCppCli)" />
</ItemGroup>
<FilterItem1ByItem2 Item1="%40(ReferencePath->'%25(NuGetPackageId)')"
PreserveItem1Metadata="true"
Item2="%40(AdditionalNugetIds)"
Metadata2="Identity">
<Output ItemName="_NugetReferencesForCppCli" TaskParameter="Result" />
</FilterItem1ByItem2>
</Target>
<ItemGroup>
<NugetReferencesForCppCli Include="%40(_NugetReferencesForCppCli->'%25(OriginalItemSpec)')" />
</ItemGroup>
</Project>
]]>
</Text>
</CppClrSupportProject>
</ItemGroup>

<MakeDir Condition="!Exists('$(IntermediateOutputPath)CppCliSupport\')"
Directories="$(IntermediateOutputPath)CppCliSupport\" />

<Delete Files="$(CppCliHelperProject)" Condition="Exists('$(CppCliHelperProject)')" />

<WriteLinesToFile Lines="%(CppClrSupportProject.Text)"
File="$(CppCliHelperProject)"
Overwrite="false" WriteOnlyWhenDifferent="false" />

<!--
Do not build - just ask ResolveReferences + IdentifyNetCoreReferences for the information
we are looking for, namely the list of .NET Core Sdk references.
-->
<ItemGroup>
<ProjectToBuild Remove="@(ProjectToBuild)" />
<ProjectToBuild Include="$(CppCliHelperProject)">
<AdditionalProperties>AdditionalPackages=@(AdditionalPackageReference->'%(Identity)+%(Version)')</AdditionalProperties>
</ProjectToBuild>
</ItemGroup>
<MSBuild Projects="@(ProjectToBuild)"
Targets="Restore;ResolveReferences;IdentifyNugetReferences"
Properties="TargetFramework=$(TargetFramework);Platform=$(Architecture);RuntimeIdentifier=win-$(Architecture)">
<Output TaskParameter="TargetOutputs" ItemName="NugetReferencesForCppCli" />
</MSBuild>

<!--
Add the newly discovered list of .NET core references to $(AdditionalExplicitAssemblyReferences)
-->
<ItemGroup Condition="'$(CopyTransitiveReferences)'=='false'">
<Reference Include="@(NugetReferencesForCppCli)">
<Private>False</Private>
</Reference>
</ItemGroup>

<ItemGroup Condition="'$(CopyTransitiveReferences)'!='false'">
<Reference Include="@(NugetReferencesForCppCli)" />
</ItemGroup>
</Target>


<PropertyGroup Condition="'$(ManagedCxx)'!='true'">
<ResolveReferencesDependsOn>
CppHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
</ItemGroup>
<PropertyGroup>
<UseDestinationLibFolder>true</UseDestinationLibFolder>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<RestoreProjectStyle>Unknown</RestoreProjectStyle>
<!--
Opting out of this to ensure _WindowsBaseReference is used as
OutputItemsType in the project reference later.
Expand Down Expand Up @@ -86,11 +84,8 @@
<CLCompile Include="main.cpp" />
<CLCompile Include="OtherAssemblyAttrs.cpp" />
</ItemGroup>
<!--
PackageReferences to pass to CppCliHelper target
-->
<ItemGroup>
<AdditionalPackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
<PackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
</ItemGroup>
<!--
Ignore ijwhost.dll during packaging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
</ItemGroup>
<PropertyGroup>
<UseDestinationLibFolder>true</UseDestinationLibFolder>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
<RestoreProjectStyle>Unknown</RestoreProjectStyle>
<!--
Opting out of this to ensure _defineReference is used as
OutputItemsType in the project references later.
Expand Down Expand Up @@ -155,11 +152,8 @@
<Define>REACHFRAMEWORK_DLL</Define>
</ProjectReference>
</ItemGroup>
<!--
PackageReferences to pass to CppCliHelper target
-->
<ItemGroup>
<AdditionalPackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
<PackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
</ItemGroup>
<!--
Ignore ijwhost.dll during packaging
Expand Down
Loading