/ Directory.Build.targets
Directory.Build.targets
1 <Project> 2 <Sdk Name="Microsoft.Build.CopyOnWrite" Version="1.0.282" /> 3 4 <Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" /> 5 <Import Project="$(MSBuildCacheSharedCompilationPackageRoot)\build\Microsoft.MSBuildCache.SharedCompilation.targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" /> 6 7 <!-- Override ManifestTool to the x64 host tool under WindowsSdkDir for all projects once the SDK path is known. --> 8 <PropertyGroup Label="ManifestToolOverride"> 9 <ManifestTool Condition="Exists('$(WindowsSdkDir)bin\x64\mt.exe')">$(WindowsSdkDir)bin\x64\mt.exe</ManifestTool> 10 </PropertyGroup> 11 12 <!-- Auto-restore NuGet for native vcxproj (PackageReference) when building inside VS --> 13 <Target Name="EnsureNuGetRestoreForVcxproj" BeforeTargets="PrepareForBuild" Condition=" 14 '$(BuildingInsideVisualStudio)' == 'true' 15 and '$(DesignTimeBuild)' != 'true' 16 and '$(RestoreInProgress)' != 'true' 17 and '$(MSBuildProjectExtension)' == '.vcxproj' 18 and '$(RestoreProjectStyle)' == 'PackageReference' 19 and '$(MSBuildProjectExtensionsPath)' != '' 20 and !Exists('$(MSBuildProjectExtensionsPath)project.assets.json') 21 "> 22 23 <Message Importance="normal" Text="NuGet assets missing for $(MSBuildProjectName); running Restore...; IntDir=$(IntDir); BaseIntermediateOutputPath=$(BaseIntermediateOutputPath)" /> 24 25 <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Restore" Properties="RestoreInProgress=true" BuildInParallel="false" /> 26 </Target> 27 28 <PropertyGroup Condition="'$(IgnoreExperimentalWarnings)' == 'true'"> 29 <NoWarn>$(NoWarn);CS8305;SA1500;CA1852</NoWarn> 30 </PropertyGroup> 31 32 <!-- Skipped test projects when BuildTests=false: no-op build and remove references. 33 This must be in targets (not props) so it runs AFTER the project file adds its items. --> 34 <PropertyGroup Condition="'$(_IsSkippedTestProject)' == 'true'"> 35 <BuildDependsOn /> 36 <CoreBuildDependsOn /> 37 <RebuildDependsOn /> 38 </PropertyGroup> 39 40 <!-- For C# projects: remove all items --> 41 <ItemGroup Condition="'$(_IsSkippedTestProject)' == 'true' and '$(MSBuildProjectExtension)' == '.csproj'"> 42 <PackageReference Remove="@(PackageReference)" /> 43 <ProjectReference Remove="@(ProjectReference)" /> 44 <Reference Remove="@(Reference)" /> 45 <Compile Remove="@(Compile)" /> 46 <Content Remove="@(Content)" /> 47 <EmbeddedResource Remove="@(EmbeddedResource)" /> 48 <None Remove="@(None)" /> 49 <Using Remove="@(Using)" /> 50 <GlobalUsing Remove="@(GlobalUsing)" /> 51 </ItemGroup> 52 53 <!-- For C++ projects (vcxproj): remove all compile/link items to prevent build --> 54 <ItemGroup Condition="'$(_IsSkippedTestProject)' == 'true' and '$(MSBuildProjectExtension)' == '.vcxproj'"> 55 <ClCompile Remove="@(ClCompile)" /> 56 <ClInclude Remove="@(ClInclude)" /> 57 <Link Remove="@(Link)" /> 58 <Lib Remove="@(Lib)" /> 59 <ProjectReference Remove="@(ProjectReference)" /> 60 <None Remove="@(None)" /> 61 <ResourceCompile Remove="@(ResourceCompile)" /> 62 <Midl Remove="@(Midl)" /> 63 </ItemGroup> 64 65 <!-- Note: For C++ skipped test projects, build is effectively skipped by removing all compile items above. 66 We don't define empty Build/Rebuild/Clean targets here because MSBuild Target definitions with Condition 67 on the Target element still override the default targets even when condition is false. --> 68 </Project>