-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow NuGetPackageRoot out of Tools.proj restore #14879
base: main
Are you sure you want to change the base?
Changes from 5 commits
6534a64
28df9e5
5b27bb6
50dd41d
b7f3b91
85fba11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Project> | ||
<!-- Disables the _CopyFilesMarkedCopyLocal target by overriding it --> | ||
<Target Name="_CopyFilesMarkedCopyLocal" /> | ||
</Project> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment to this and the other two files at the beginning of the file and link to the origin. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ➡️ Now updated |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Licensed under the MIT license. | ||
--> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<PropertyGroup> | ||
<UsingMicrosoftNoTargetsSdk>true</UsingMicrosoftNoTargetsSdk> | ||
<MSBuildAllProjects Condition="'$(MSBuildToolsVersion)' != 'Current'">$(MSBuildAllProjects);$(MsBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- Copy logic to know if managed targets got imported: https://github.com/dotnet/sdk/blob/49002c14cf91ecd08e79d6184dbd4716c005b509/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L25-L27 --> | ||
<ManagedLanguageTargetsGotImported Condition="'$(MSBuildProjectExtension)' == '.csproj'">true</ManagedLanguageTargetsGotImported> | ||
<ManagedLanguageTargetsGotImported Condition="'$(MSBuildProjectExtension)' == '.vbproj'">true</ManagedLanguageTargetsGotImported> | ||
<ManagedLanguageTargetsGotImported Condition="'$(MSBuildProjectExtension)' == '.fsproj'">true</ManagedLanguageTargetsGotImported> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(CustomBeforeNoTargetsProps)" Condition=" '$(CustomBeforeNoTargetsProps)' != '' And Exists('$(CustomBeforeNoTargetsProps)') " /> | ||
|
||
<PropertyGroup> | ||
<!-- Disable default Compile and EmbeddedResource items for NoTargets projects --> | ||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> | ||
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems> | ||
|
||
<!-- | ||
NuGet should always restore Traversal projects with "PackageReference" style restore. Setting this property will cause the right thing to happen even if there aren't any PackageReference items in the project. | ||
--> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
|
||
<!-- Targeting packs shouldn't be referenced as traversal projects don't compile. --> | ||
<DisableImplicitFrameworkReferences Condition="'$(DisableImplicitFrameworkReferences)' == ''">true</DisableImplicitFrameworkReferences> | ||
|
||
<!-- Disable publish actions --> | ||
<CopyBuildOutputToPublishDirectory Condition="'$(CopyBuildOutputToPublishDirectory)' == ''">false</CopyBuildOutputToPublishDirectory> | ||
<CopyOutputSymbolsToPublishDirectory Condition="'$(CopyOutputSymbolsToPublishDirectory)' == ''">false</CopyOutputSymbolsToPublishDirectory> | ||
|
||
<!-- Don't generate a deps file --> | ||
<GenerateDependencyFile Condition="'$(GenerateDependencyFile)' == ''">false</GenerateDependencyFile> | ||
|
||
<!-- Don't generate assembly info --> | ||
<GenerateAssemblyInfo Condition="'$(GenerateAssemblyInfo)' == ''">false</GenerateAssemblyInfo> | ||
|
||
<!-- Don't generate editor config file --> | ||
<GenerateMSBuildEditorConfigFile Condition="'$(GenerateMSBuildEditorConfigFile)' == ''">false</GenerateMSBuildEditorConfigFile> | ||
|
||
<!-- Don't log the high priority message mentioning this project's name (or copy the product we didn't build). --> | ||
<SkipCopyBuildProduct Condition="'$(SkipCopyBuildProduct)' == ''">true</SkipCopyBuildProduct> | ||
|
||
<!-- Don't automatically reference assembly packages since NoTargets don't need reference assemblies --> | ||
<AutomaticallyUseReferenceAssemblyPackages Condition="'$(AutomaticallyUseReferenceAssemblyPackages)' == ''">false</AutomaticallyUseReferenceAssemblyPackages> | ||
<NoCompilerStandardLib Condition="'$(NoCompilerStandardLib)' == ''">false</NoCompilerStandardLib> | ||
<NoStdLib Condition="'$(NoStdLib)' == ''">true</NoStdLib> | ||
|
||
<!-- Disable Visual Studio's Fast Up-to-date Check and rely on MSBuild to determine --> | ||
<DisableFastUpToDateCheck Condition="'$(DisableFastUpToDateCheck)' == ''">true</DisableFastUpToDateCheck> | ||
</PropertyGroup> | ||
|
||
<ItemDefinitionGroup Condition=" '$(NoTargetsDoNotReferenceOutputAssemblies)' != 'false' "> | ||
<ProjectReference> | ||
<!-- | ||
Setting ReferenceOutputAssembly skips target framework cross-project validation in NuGet. Since NoTargets projects don't define runtime | ||
constraints like a target framework, there's no point in checking the compatibilty of project references. | ||
--> | ||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> | ||
</ProjectReference> | ||
</ItemDefinitionGroup> | ||
|
||
<Target Name="CreateManifestResourceNames" /> | ||
|
||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition=" '$(MicrosoftCommonPropsHasBeenImported)' != 'true' "/> | ||
|
||
<Import Project="$(CustomAfterNoTargetsProps)" Condition=" '$(CustomAfterNoTargetsProps)' != '' And Exists('$(CustomAfterNoTargetsProps)') " /> | ||
|
||
<!-- For CPS/VS support. Importing in .props allows any subsequent targets to redefine this if needed --> | ||
<Target Name="CompileDesignTime" /> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Licensed under the MIT license. | ||
--> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<!-- | ||
Set LanguageTargets to Microsoft.Common.targets for any project that the SDK won't (.proj, .noproj, etc) | ||
https://github.com/dotnet/sdk/blob/50ddfbb91be94d068514e8f4b0ce1052156364a0/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L28 | ||
|
||
We can't default LanguageTargets it is set in the SDK and immediately imported. So we can only default | ||
it if we know the SDK won't. Projects probably won't load in Visual Studio but will build from the | ||
command-line just fine. | ||
--> | ||
<PropertyGroup> | ||
<LanguageTargets Condition=" '$(LanguageTargets)' == '' And '$(MSBuildProjectExtension)' != '.csproj' And '$(MSBuildProjectExtension)' != '.vbproj' And '$(MSBuildProjectExtension)' != '.fsproj' ">$(MSBuildToolsPath)\Microsoft.Common.targets</LanguageTargets> | ||
<MSBuildAllProjects Condition="'$(MSBuildToolsVersion)' != 'Current'">$(MSBuildAllProjects);$(MsBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(CustomBeforeNoTargets)" Condition="'$(CustomBeforeNoTargets)' != '' and Exists('$(CustomBeforeNoTargets)')" /> | ||
|
||
<PropertyGroup> | ||
<!-- Don't include build output in a package since NoTargets projects don't emit an assembly. --> | ||
<IncludeBuildOutput Condition="'$(IncludeBuildOutput)' == ''">false</IncludeBuildOutput> | ||
|
||
<!-- For CPS/VS support. See https://github.com/dotnet/project-system/blob/master/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/DesignTimeTargets/Microsoft.Managed.DesignTime.targets#L60 --> | ||
<CustomBeforeMicrosoftCommonTargets Condition="'$(ManagedLanguageTargetsGotImported)' == '' And Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets')">$(CustomBeforeMicrosoftCommonTargets);$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets</CustomBeforeMicrosoftCommonTargets> | ||
</PropertyGroup> | ||
|
||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition=" '$(CommonTargetsPath)' == '' " /> | ||
|
||
<PropertyGroup> | ||
<!-- This property must be overridden to remove a few targets that compile assemblies --> | ||
<CoreBuildDependsOn> | ||
BuildOnlySettings; | ||
PrepareForBuild; | ||
PreBuildEvent; | ||
ResolveReferences; | ||
Compile; | ||
GetTargetPath; | ||
PrepareForRun; | ||
IncrementalClean; | ||
PostBuildEvent | ||
</CoreBuildDependsOn> | ||
|
||
<!-- Disable symbol generation --> | ||
<DebugType>None</DebugType> | ||
<DebugSymbols>false</DebugSymbols> | ||
|
||
<!-- Don't emit a reference assembly --> | ||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
<!-- Clear output group items which are read by the IDE and NuGet. --> | ||
<ItemGroup> | ||
<BuiltProjectOutputGroupKeyOutput Remove="@(BuiltProjectOutputGroupKeyOutput)" /> | ||
<DebugSymbolsProjectOutputGroupOutput Remove="@(DebugSymbolsProjectOutputGroupOutput)" /> | ||
<IntermediateAssembly Remove="@(IntermediateAssembly)" /> | ||
<IntermediateRefAssembly Remove="@(IntermediateRefAssembly)" /> | ||
<Reference Remove="mscorlib" /> | ||
</ItemGroup> | ||
|
||
<!-- | ||
The CopyFilesToOutputDirectory target is hard coded to depend on ComputeIntermediateSatelliteAssemblies. NoTargets projects do no generate resource assemblies | ||
so the target is replaced with a no-op | ||
--> | ||
<Target Name="ComputeIntermediateSatelliteAssemblies" /> | ||
|
||
<!-- | ||
NoTargets projects do not build an assembly so dependent projects shouldn't get a path to the target. Override the GetTargetPath to do nothing. | ||
--> | ||
<Target Name="GetTargetPath" /> | ||
|
||
<!-- | ||
The GetTargetPathWithTargetPlatformMoniker target uses a BeforeTargets so the only way to disable it is to override it with an empty target. | ||
--> | ||
<Target Name="GetTargetPathWithTargetPlatformMoniker" /> | ||
|
||
<!-- | ||
The GetReferenceAssemblyPaths does not need to run since reference assemblies aren't needed. | ||
--> | ||
<Target Name="GetFrameworkPaths" DependsOnTargets="$(GetFrameworkPathsDependsOn)" /> | ||
<Target Name="GetReferenceAssemblyPaths" DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn)" /> | ||
|
||
<Import Project="$(CustomAfterNoTargets)" Condition="'$(CustomAfterNoTargets)' != '' and Exists('$(CustomAfterNoTargets)')" /> | ||
|
||
<!-- | ||
Microsoft.Managed.Targets is imported by the managed language target files in MSBuild 16.0 and above, but most of the msbuild tasks are actually in Microsoft.Common.Currentversion.targets. | ||
So import it when the managed targets do not get imported. | ||
--> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.targets" Condition="'$(MSBuildAssemblyVersion)' >= '16.0' And '$(ManagedLanguageTargetsGotImported)' != 'true'" /> | ||
|
||
<!-- Override stock CoreCompile target to do nothing but keep extensibility points --> | ||
<Target Name="CoreCompile" | ||
DependsOnTargets="$(CoreCompileDependsOn)"> | ||
<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''" /> | ||
</Target> | ||
|
||
<Target Name="_GenerateCompileInputs" /> | ||
<Target Name="_GenerateCompileDependencyCache" /> | ||
|
||
<!-- Disables the _CopyFilesMarkedCopyLocal target to not copy references when SkipCopyFilesMarkedCopyLocal is set to false. --> | ||
<Import Project="Microsoft.Build.NoTargets.3.7.56.DisableCopyFilesMarkedCopyLocal.targets" Condition="'$(SkipCopyFilesMarkedCopyLocal)' == 'true'" /> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. --> | ||
<Project> | ||
|
||
<Import Project="Microsoft.Build.NoTargets.3.7.56.Sdk.props"/> | ||
|
||
<Import Project="BuildStep.props" /> | ||
|
||
<!-- Properties requires by NuGet.targets to restore PackageReferences --> | ||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<!-- Workaround changes from newer MSBuild requiring additional properties --> | ||
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">5</TargetFrameworkVersion> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 This value was simply wrong, and after updating to use Microsoft.Build.Traversal it was resulting in build errors. |
||
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.7.2</TargetFrameworkVersion> | ||
<TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier> | ||
<TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">.NETFramework,Version=v4.7.2</TargetFrameworkMoniker> | ||
<MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath> | ||
|
@@ -86,6 +88,10 @@ | |
Condition="'$(Restore)' == 'true'"/> | ||
</Target> | ||
|
||
<Target Name="ReturnNuGetPackageRoot" Returns="$(NuGetPackageRoot)"> | ||
<Error Text="Unable to determine 'NuGetPackageRoot' prior to restore." Condition="'$(NuGetPackageRoot)' == ''" /> | ||
</Target> | ||
|
||
<Import Project="SourceBuild/SourceBuildArcadeTools.targets" Condition="'$(ArcadeBuildFromSource)' == 'true' or | ||
'$(DotNetBuildRepo)' == 'true' or | ||
'$(SetUpSourceBuildIntermediateNupkgCache)' == 'true'" /> | ||
|
@@ -97,4 +103,6 @@ | |
|
||
<Import Project="VisualStudio.AcquireOptimizationData.targets" Condition="'$(UsingToolVisualStudioIbcTraining)' == 'true'" /> | ||
|
||
<Import Project="Microsoft.Build.NoTargets.3.7.56.Sdk.targets"/> | ||
|
||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Setting this property forces Tools.proj.nuget.g.props to not be included. This is fine on the restore path, but we need to avoid it when invoking the
ReturnNuGetPackageRoot
target.