Files
PowerToys/Directory.Build.targets
Gordon Lam 9aca6d136f Revert "Revert commit" - Using centralized package management for vcxproj (#44289)
Reverts microsoft/PowerToys#44208
Basically enable back: https://github.com/microsoft/PowerToys/pull/43920

the core change is adding this new Target to ensure when "building in
Visual Studio", it will restore the nuget package first for vcxproj:
```xml
  <!-- Auto-restore NuGet for native vcxproj (PackageReference) when building inside VS -->
  <Target Name="EnsureNuGetRestoreForVcxproj" BeforeTargets="PrepareForBuild" Condition="
            '$(BuildingInsideVisualStudio)' == 'true'
            and '$(DesignTimeBuild)' != 'true'
            and '$(RestoreInProgress)' != 'true'
            and '$(MSBuildProjectExtension)' == '.vcxproj'
            and '$(RestoreProjectStyle)' == 'PackageReference'
            and '$(MSBuildProjectExtensionsPath)' != ''
            and !Exists('$(MSBuildProjectExtensionsPath)project.assets.json')
          ">

    <Message Importance="normal" Text="NuGet assets missing for $(MSBuildProjectName); running Restore...; IntDir=$(IntDir); BaseIntermediateOutputPath=$(BaseIntermediateOutputPath)" />

    <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Restore" Properties="RestoreInProgress=true" BuildInParallel="false" />
  </Target>
```
2025-12-16 10:46:39 +08:00

27 lines
1.6 KiB
XML

<Project>
<Sdk Name="Microsoft.Build.CopyOnWrite" Version="1.0.282" />
<Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" />
<Import Project="$(MSBuildCacheSharedCompilationPackageRoot)\build\Microsoft.MSBuildCache.SharedCompilation.targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" />
<!-- Override ManifestTool to the x64 host tool under WindowsSdkDir for all projects once the SDK path is known. -->
<PropertyGroup Label="ManifestToolOverride">
<ManifestTool Condition="Exists('$(WindowsSdkDir)bin\x64\mt.exe')">$(WindowsSdkDir)bin\x64\mt.exe</ManifestTool>
</PropertyGroup>
<!-- Auto-restore NuGet for native vcxproj (PackageReference) when building inside VS -->
<Target Name="EnsureNuGetRestoreForVcxproj" BeforeTargets="PrepareForBuild" Condition="
'$(BuildingInsideVisualStudio)' == 'true'
and '$(DesignTimeBuild)' != 'true'
and '$(RestoreInProgress)' != 'true'
and '$(MSBuildProjectExtension)' == '.vcxproj'
and '$(RestoreProjectStyle)' == 'PackageReference'
and '$(MSBuildProjectExtensionsPath)' != ''
and !Exists('$(MSBuildProjectExtensionsPath)project.assets.json')
">
<Message Importance="normal" Text="NuGet assets missing for $(MSBuildProjectName); running Restore...; IntDir=$(IntDir); BaseIntermediateOutputPath=$(BaseIntermediateOutputPath)" />
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Restore" Properties="RestoreInProgress=true" BuildInParallel="false" />
</Target>
</Project>