Skip to content
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

Small fixes for recent work in VSIX up-to-date checks and path detection #14868

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ function GetNuGetPackageCachePath() {
# global packages folder, this expression will evaluate to the empty string which will effectively leave the
# environment variable set to null.
$env:NUGET_PACKAGES = $nugetConfigXml.SelectSingleNode("//configuration/config/add[@key='globalPackagesFolder']").value
if ($env:NUGET_PACKAGES -ne $null) {
# Join-Path with an empty child path effectively adds a trailing directory separator only if one does not
# already exist
$env:NUGET_PACKAGES = Join-Path $env:NUGET_PACKAGES ''
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 This makes me a bit uncomfortable; let me know if it's acceptable or if there is a better way to do it.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$env:NUGET_PACKAGES = Join-Path $env:NUGET_PACKAGES ''
$env:NUGET_PACKAGES = Join-Path $env:NUGET_PACKAGES $([IO.Path]::DirectorySeparatorChar)

This appears to do the correct thing locally.

}
}

if ($env:NUGET_PACKAGES -eq $null) {
Expand Down
35 changes: 25 additions & 10 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,35 @@
</ItemGroup>

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

<_RestoreProps Include="@(_CommonProps)"/>
<_RestoreProps Include="ExcludeRestorePackageImports=true"/>
<_RestoreProps Include="_NuGetRestoreTargets=$(_NuGetRestoreTargets)"/>

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

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

<!-- Forward this property because we can't assume it will be available globally. -->
<_RestoreToolsProps Include="DotNetPublishUsingPipelines=$(DotNetPublishUsingPipelines)"/>
<_RestoreProps 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)"/>
<_RestoreProps Include="DotNetRuntimeSourceFeed=$(DotNetRuntimeSourceFeed)"/>
<_RestoreProps Include="DotNetRuntimeSourceFeedKey=$(DotNetRuntimeSourceFeedKey)"/>
</ItemGroup>

<ItemGroup Condition="'$(Restore)' == 'true'">
<_RestoreToolsProps Include="@(_RestoreProps)"/>
<_RestoreToolsProps Include="BaseIntermediateOutputPath=$(ArtifactsToolsetDir)Common"/>

<_RestoreSignProps Include="@(_RestoreProps)"/>
<_RestoreSignProps Include="BaseIntermediateOutputPath=$(ArtifactsToolsetDir)CommonSign"/>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -185,6 +192,14 @@
Properties="@(_RestoreToolsProps);_NETCORE_ENGINEERING_TELEMETRY=Restore"
Condition="'$(Restore)' == 'true'"/>

<!--
Restore built-in tools for signing.
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 Restoring Sign.proj is the step that defines NuGetPackageRoot for use within it.

-->
<MSBuild Projects="Sign.proj"
Targets="Restore"
Properties="@(_RestoreSignProps);_NETCORE_ENGINEERING_TELEMETRY=Restore"
Condition="'$(Restore)' == 'true'"/>

<!--
Restore solutions and projects.

Expand Down
51 changes: 51 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,57 @@

<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>
<TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">.NETFramework,Version=v4.7.2</TargetFrameworkMoniker>
<MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>
</PropertyGroup>

<!--
Configure NuGet Restore to use NuGet.config file in the repository root.
We could drop a custom NuGet.config to the containing directory but it's simpler
if we use the same config for all restore operations.
NuGet.Config, NuGet.config, and nuget.config are all allowed casings according to NuGet:
https://github.com/NuGet/NuGet.Client/blob/b83566ec2369c4e9fd07e6f95d734dfe370a1e66/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L34-L36
-->
<PropertyGroup Condition="'$(RestoreConfigFile)' == ''">
<RestoreConfigFile Condition="Exists('$(RepoRoot)NuGet.config')">$(RepoRoot)NuGet.config</RestoreConfigFile>
<RestoreConfigFile Condition="Exists('$(RepoRoot)NuGet.Config')">$(RepoRoot)NuGet.Config</RestoreConfigFile>
<RestoreConfigFile Condition="Exists('$(RepoRoot)nuget.config')">$(RepoRoot)nuget.config</RestoreConfigFile>
</PropertyGroup>

<Import Project="$(_NuGetRestoreTargets)" />

<!-- These package references should only be excluded when doing inner builds, and outer-builds from the orchestrator in source only build
configurations. non-source only build configurations should always restore these packages.

Switches are separated by legacy vs. new.

This looks complicated right now, but will get simpler as legacy switches disappear:
- ArcadeInnerBuildFromSource/DotNetBuildFromSource disappear:
('$(DotNetBuildSourceOnly)' != 'true' or ('$(DotNetBuildPhase)' == 'Repo' and '$(DotNetBuildOrchestrator)' != 'true')
-->

<PropertyGroup>
<_ImportOrUseTooling>false</_ImportOrUseTooling>
<_ImportOrUseTooling Condition="('$(ArcadeInnerBuildFromSource)' != 'true' and '$(DotNetBuildFromSourceFlavor)' != 'Product') and
('$(DotNetBuildSourceOnly)' != 'true' or ('$(DotNetBuildPhase)' == 'Repo' and '$(DotNetBuildOrchestrator)' != 'true'))">true</_ImportOrUseTooling>
</PropertyGroup>

<ItemGroup Condition="'$(_ImportOrUseTooling)' == 'true'">
<!-- Copy of 'sn.exe' in form of NuGet package. -->
<PackageReference Include="sn" Version="$(SNVersion)" IsImplicitlyDefined="true" />
<PackageReference Include="MicroBuild.Core" Version="$(MicroBuildCoreVersion)" IsImplicitlyDefined="true" />
<PackageReference Include="MicroBuild.Core.Sentinel" Version="1.0.0" IsImplicitlyDefined="true" />
<PackageReference Include="vswhere" Version="$(VSWhereVersion)" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.Signed.Wix" Version="$(MicrosoftSignedWixVersion)" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.DotNet.SignTool" Version="$(MicrosoftDotNetSignToolVersion)" IsImplicitlyDefined="true" />
</ItemGroup>

<Import Project="$(NuGetPackageRoot)microsoft.dotnet.signtool\$(MicrosoftDotNetSignToolVersion)\build\Microsoft.DotNet.SignTool.props" />

<Import Project="Sign.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
<!--
Make sure to include information about inputs and outputs to CreateVsixContainer for fast up-to-date check.
-->
<PropertyGroup>
<PropertyGroup Condition="'$(VSToolsPath)' != '' and ('$(IsVsixProject)' == 'true' or '$(GeneratePkgDefFile)' == 'true')">
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 This is the same condition used above for conditional import of VisualStudio.ImportSdk.targets

<CollectUpToDateCheckInputDesignTimeDependsOn>$(CollectUpToDateCheckInputDesignTimeDependsOn);CollectVsixUpToDateCheckInput</CollectUpToDateCheckInputDesignTimeDependsOn>
<CollectUpToDateCheckBuiltDesignTimeDependsOn>$(CollectUpToDateCheckBuiltDesignTimeDependsOn);CollectVsixUpToDateCheckBuilt</CollectUpToDateCheckBuiltDesignTimeDependsOn>
</PropertyGroup>
Expand Down
Loading