-
Notifications
You must be signed in to change notification settings - Fork 354
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
Open
tmat
wants to merge
6
commits into
dotnet:main
Choose a base branch
from
tmat:FlowNuGetPackageRoot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6534a64
Flow NuGetPackageRoot out of Tools.proj restore
tmat 28df9e5
Flow NuGetPackageRoot even on non-Restore paths
sharwell 5b27bb6
Use Microsoft.Build.Traversal for Tools.proj to import NuGet targets …
sharwell 50dd41d
Use Microsoft.Build.NoTargets instead of Microsoft.Build.Traversal
sharwell b7f3b91
Inline Microsoft.Build.NoTargets to avoid a reference to an external SDK
sharwell 85fba11
Add attribution notice
sharwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...Arcade.Sdk/tools/Microsoft.Build.NoTargets.3.7.56.DisableCopyFilesMarkedCopyLocal.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- Sourced from NuGet package Microsoft.Build.NoTargets --> | ||
<Project> | ||
<!-- Disables the _CopyFilesMarkedCopyLocal target by overriding it --> | ||
<Target Name="_CopyFilesMarkedCopyLocal" /> | ||
</Project> |
81 changes: 81 additions & 0 deletions
81
src/Microsoft.DotNet.Arcade.Sdk/tools/Microsoft.Build.NoTargets.3.7.56.Sdk.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Licensed under the MIT license. | ||
--> | ||
<!-- Sourced from NuGet package Microsoft.Build.NoTargets --> | ||
<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> |
107 changes: 107 additions & 0 deletions
107
src/Microsoft.DotNet.Arcade.Sdk/tools/Microsoft.Build.NoTargets.3.7.56.Sdk.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Licensed under the MIT license. | ||
--> | ||
<!-- Sourced from NuGet package Microsoft.Build.NoTargets --> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.