Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
50 changes: 32 additions & 18 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,51 @@
<_CommonProps Include="VCTargetsPath=$([MSBuild]::ValueOrDefault('$(VCTargetsPath)', '$([MSBuild]::GetVsInstallRoot())\Common7\IDE\VC\VCTargets\'))" Condition="'$(MSBuildRuntimeType)' != 'Core'"/>
</ItemGroup>

<ItemGroup Condition="'$(Restore)' == 'true'">
<_RestoreToolsProps Include="@(_CommonProps)"/>
<_RestoreToolsProps Include="BaseIntermediateOutputPath=$(ArtifactsToolsetDir)Common"/>
<_RestoreToolsProps Include="ExcludeRestorePackageImports=true"/>
Copy link
Contributor

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.

<_RestoreToolsProps Include="_NuGetRestoreTargets=$(_NuGetRestoreTargets)"/>
<ItemGroup>
<_CommonToolsProps Include="@(_CommonProps)"/>
<_CommonToolsProps Include="BaseIntermediateOutputPath=$(ArtifactsToolsetDir)Common"/>
<_CommonToolsProps Include="_NuGetRestoreTargets=$(_NuGetRestoreTargets)"/>

<!-- Used in the SDK (Tools.proj) to control whether Build.Tasks.Feed will be restored or not. -->
<_RestoreToolsProps Include="Publish=$(Publish)"/>
<_CommonToolsProps Include="Publish=$(Publish)"/>

<!-- Used in the SDK (Tools.proj) to control whether SymbolUploader.Build.Task will be restored or not. -->
<_RestoreToolsProps Include="PublishToSymbolServer=$(PublishToSymbolServer)"/>
<_CommonToolsProps Include="PublishToSymbolServer=$(PublishToSymbolServer)"/>

<!-- Forward this property because we can't assume it will be available globally. -->
<_RestoreToolsProps Include="DotNetPublishUsingPipelines=$(DotNetPublishUsingPipelines)"/>
<_CommonToolsProps Include="DotNetPublishUsingPipelines=$(DotNetPublishUsingPipelines)"/>
</ItemGroup>

<!--
Builds from the 'internal' project, and only those, can download the .net Runtime
from a private location.
-->
<ItemGroup Condition="'$(SYSTEM_TEAMPROJECT)' == 'internal'">
<_RestoreToolsProps Include="DotNetRuntimeSourceFeed=$(DotNetRuntimeSourceFeed)"/>
<_RestoreToolsProps Include="DotNetRuntimeSourceFeedKey=$(DotNetRuntimeSourceFeedKey)"/>
<_CommonToolsProps Include="DotNetRuntimeSourceFeed=$(DotNetRuntimeSourceFeed)"/>
<_CommonToolsProps Include="DotNetRuntimeSourceFeedKey=$(DotNetRuntimeSourceFeedKey)"/>
</ItemGroup>

<ItemGroup>
<_RestoreToolsProps Include="@(_CommonToolsProps)"/>
<_RestoreToolsProps Include="ExcludeRestorePackageImports=true"/>
</ItemGroup>

<!--
Restore built-in tools if requested, and extract information from the NuGet restore output.
-->
<MSBuild Projects="Tools.proj"
Targets="Restore"
Properties="@(_RestoreToolsProps);_NETCORE_ENGINEERING_TELEMETRY=Restore"
Condition="'$(Restore)' == 'true'"/>

<MSBuild Projects="Tools.proj"
Targets="ReturnNuGetPackageRoot"
Properties="@(_CommonToolsProps);_NETCORE_ENGINEERING_TELEMETRY=ReturnNuGetPackageRoot">
<Output TaskParameter="TargetOutputs" ItemName="_RestoreToolsOutput" />
</MSBuild>

<ItemGroup>
<_CommonProps Include="@(_RestoreToolsOutput->'NuGetPackageRoot=%(Identity)')"/>
</ItemGroup>

<ItemGroup>
Expand All @@ -177,14 +199,6 @@
<_SolutionBuildProps Include="__ImportPackTargets=true" Condition="'$(Pack)' == 'true'" />
</ItemGroup>

<!--
Restore built-in tools.
-->
<MSBuild Projects="Tools.proj"
Targets="Restore"
Properties="@(_RestoreToolsProps);_NETCORE_ENGINEERING_TELEMETRY=Restore"
Condition="'$(Restore)' == 'true'"/>

<!--
Restore solutions and projects.
Expand Down
8 changes: 6 additions & 2 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Tools.proj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>
<Project Sdk="Microsoft.Build.Traversal">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 This is the easiest way to include Microsoft.Common.targets, which is how Tools.proj.nuget.g.props gets included during evaluation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the version for this msbuild sdk stored?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add it anywhere so far. Do I need to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NuGet needs a version for any to be imported msbuild sdk. This change will break all consuming repositories that don't define a version in their global.json file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Switched to Microsoft.Build.NoTargets, which has a version already defined in global.json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell I don't think that's the case for all consuming repositories, and there are 150+ branches/repos that consume arcade built from this branch. That will be a big lift to get everyone onboarded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to do this as an opt-in, or provide a smooth transition?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ This no longer references a separate SDK

Copy link
Member

@ViktorHofer ViktorHofer Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Traversal msbuild sdk should be used when a project needs to traverse the msbuild project graph. I don't see any ProjectReferences defined in this project so Microsoft.Build.NoTargets would be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testing, Microsoft.Build.NoTargets seemed to work fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Now switched to Microsoft.Build.NoTargets

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Now switched to a local definition


<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>
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
Expand Down Expand Up @@ -86,6 +86,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'" />
Expand Down