Skip to content

Add analyzer redirecting VSIX #42861

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

Merged
merged 31 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
62154cf
Add analyzer redirecting VSIX
jjonescz Aug 20, 2024
cdb4892
Fix infra
jjonescz Aug 26, 2024
2ed93ed
Merge branch 'main' into analyzer-redirecting
jjonescz Aug 26, 2024
53a5074
Add to UnitTests.proj
jjonescz Aug 26, 2024
5928f32
Implement path redirect
jjonescz Aug 29, 2024
5165f0f
Merge branch 'main' into analyzer-redirecting
jjonescz Aug 29, 2024
9807811
Implement redirector API
jjonescz Aug 30, 2024
4e01a87
Improve code
jjonescz Aug 30, 2024
cdac6cc
Update roslyn
jjonescz Sep 2, 2024
7a31ffb
Simplify slash handling
jjonescz Sep 2, 2024
586ced5
Simplify version matching
jjonescz Sep 2, 2024
c4a206a
Merge branch 'main' into analyzer-redirecting
jjonescz Sep 2, 2024
e65c1c0
Add transport package for VS deployment
jjonescz Sep 4, 2024
61af4e8
Merge branch 'main' into analyzer-redirecting
jjonescz Sep 4, 2024
245b2f1
Consume the API from Workspaces
jjonescz Sep 9, 2024
f5d671e
Update roslyn
jjonescz Sep 10, 2024
92e2284
Merge branch 'main' into analyzer-redirecting
jjonescz Sep 10, 2024
f0b86a4
Add comments
jjonescz Sep 13, 2024
d5a3924
Merge branch 'main' into analyzer-redirecting
jjonescz Jan 13, 2025
5da7cda
Remove Lazy
jjonescz Jan 15, 2025
6a8f110
Extend tests
jjonescz Jan 15, 2025
8680087
Update Roslyn
jjonescz Jan 15, 2025
f73918a
Merge branch 'main' into analyzer-redirecting
jjonescz Jan 15, 2025
74518c1
Extend tests
jjonescz Jan 16, 2025
d8195ab
Merge branch 'main' into analyzer-redirecting
jjonescz Feb 14, 2025
cf5c1f3
Remove testing feed
jjonescz Feb 14, 2025
8b61147
Disable GenerateRuntimeAnalyzersSWR in VMR build
jjonescz Feb 14, 2025
7116b32
Merge branch 'main' into analyzer-redirecting
jjonescz Feb 20, 2025
4c32363
Do not NGEN the new assemblies for now
jjonescz Feb 26, 2025
bde0f8d
Merge branch 'main' into analyzer-redirecting
jjonescz Feb 28, 2025
1971566
Explain why VsixVersion is needed
jjonescz Mar 10, 2025
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
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<PackageVersion Include="Microsoft.TestPlatform.Build" Version="$(MicrosoftTestPlatformBuildPackageVersion)" />
<PackageVersion Include="Microsoft.TestPlatform.CLI" Version="$(MicrosoftTestPlatformCLIPackageVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.4.16" />
<PackageVersion Include="Microsoft.VisualStudio.Sdk" Version="17.2.32505.173" />
Copy link
Member

Choose a reason for hiding this comment

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

Do you know how often these get updated and how best to keep them updated?

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 gets a non-preview release with every VS minor version. But I don't think this needs to be updated unless a new functionality from the VS SDK is needed (or if there are some transitive dependency conflicts). That's why it's fine that this is using an old version 17.2 instead of the latest 17.13 (but the real reason I chose 17.2 was because there were some conflicts with transitive dependencies IIRC).

<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.11.435" />
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="$(MicrosoftVisualStudioSetupConfigurationInteropVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.28" />
<PackageVersion Include="Microsoft.Web.Deployment" Version="$(WebDeploymentPackageVersion)" />
Expand Down
2 changes: 2 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<add key="dotnet-tools-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-transport/nuget/v3/index.json" />
<add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" />
<add key="dotnet-libraries-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries-transport/nuget/v3/index.json" />
<add key="vssdk" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json" />
<add key="vssdk-archived" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk-archived/nuget/v3/index.json" />
<add key="vs-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json" />
<!-- Used for Rich Navigation indexing task -->
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
Expand Down
5 changes: 4 additions & 1 deletion eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<FileSignInfo Include="MessagePack.Annotations.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="MessagePack.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="StreamJsonRpc.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="CommandLine.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="FluentAssertions.dll" CertificateName="$(ExternalCertificateId)" />
Expand All @@ -74,6 +73,10 @@
<FileSignInfo Include="Valleysoft.DockerCredsProvider.dll" CertificateName="$(ExternalCertificateId)" />
</ItemGroup>

<ItemGroup>
<FileSignInfo Include="StreamJsonRpc.dll" CertificateName="MicrosoftSHA2" />
</ItemGroup>

<!-- Filter out any test packages from ItemsToSign -->
<ItemGroup>
<ItemsToSign Remove="$(ArtifactsPackagesDir)**\*tests*.nupkg" />
Expand Down
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
compiler API targeted by analyzer assemblies. This is mostly an issue on source-build as
in that build mode analyzer assemblies always target the live compiler API. -->
<UsingToolMicrosoftNetCompilers Condition="'$(DotNetBuildSourceOnly)' == 'true'">true</UsingToolMicrosoftNetCompilers>
<UsingToolVSSDK>true</UsingToolVSSDK>
<MicrosoftIORedistPackageVersion>6.0.1</MicrosoftIORedistPackageVersion>
<FlagNetStandard1XDependencies Condition="'$(DotNetBuildSourceOnly)' == 'true'">true</FlagNetStandard1XDependencies>
<!-- This property is only used in the dotnet test integration tests. -->
Expand Down
14 changes: 14 additions & 0 deletions sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.HotReload.
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.DotNet.HotReload.Agent.Data", "src\BuiltInTools\HotReloadAgent.Data\Microsoft.DotNet.HotReload.Agent.Data.shproj", "{0762B436-F4B0-4008-9097-BB5FF6BD84AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.Sdk.AnalyzerRedirecting", "src\Microsoft.Net.Sdk.AnalyzerRedirecting\Microsoft.Net.Sdk.AnalyzerRedirecting.csproj", "{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.Sdk.AnalyzerRedirecting.Tests", "test\Microsoft.Net.Sdk.AnalyzerRedirecting.Tests\Microsoft.Net.Sdk.AnalyzerRedirecting.Tests.csproj", "{234BE46E-4AD6-485C-B0D3-E704EF504312}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -975,6 +979,14 @@ Global
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748}.Release|Any CPU.Build.0 = Release|Any CPU
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Release|Any CPU.Build.0 = Release|Any CPU
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Debug|Any CPU.Build.0 = Debug|Any CPU
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Release|Any CPU.ActiveCfg = Release|Any CPU
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1155,6 +1167,8 @@ Global
{FA3C7F91-42A2-45AD-897C-F646B081016C} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
{0762B436-F4B0-4008-9097-BB5FF6BD84AF} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
{234BE46E-4AD6-485C-B0D3-E704EF504312} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FB8F26CE-4DE6-433F-B32A-79183020BBD6}
Expand Down
1 change: 1 addition & 0 deletions src/Installer/redist-installer/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Import Project="targets\GenerateBundledVersions.targets" />
<Import Project="targets\Crossgen.targets" />
<Import Project="targets\GenerateLayout.targets" />
<Import Project="targets\GenerateRuntimeAnalyzers.targets" />
<Import Project="targets\Badge.targets" Condition="'$(PgoInstrument)' != 'true'" />
<Import Project="targets\GenerateArchives.targets" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers</id>
<version>1.0.0</version>
<title>VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<licenseUrl>https://www.microsoft.com/net/dotnet_library_license.htm</licenseUrl>
<projectUrl>https://github.com/dotnet/sdk</projectUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Analyzers and generators from the runtime and SDK for VS insertion</description>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
</metadata>
<files>
<file src="$PAYLOAD_FILES$\**\*" />
</files>
</package>
28 changes: 27 additions & 1 deletion src/Installer/redist-installer/targets/GenerateMSIs.targets
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<SdkPlaceholderInstallerNuspecFile>$(SdkPkgSourcesRootDirectory)/VS.Redist.Common.NetCore.SdkPlaceholder.nuspec</SdkPlaceholderInstallerNuspecFile>
<SdkPlaceholderInstallerNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.NetCore.SdkPlaceholder.$(Architecture).$(FullNugetVersion).nupkg</SdkPlaceholderInstallerNupkgFile>

<SdkRuntimeAnalyzersNuspecFile>$(SdkPkgSourcesRootDirectory)/VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.nuspec</SdkRuntimeAnalyzersNuspecFile>
<SdkRuntimeAnalyzersNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.$(FullNugetVersion).nupkg</SdkRuntimeAnalyzersNupkgFile>
<SdkRuntimeAnalyzersSwrFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.swr</SdkRuntimeAnalyzersSwrFile>

<!-- Temp directory for light command layouts -->
<LightCommandObjDir>$(ArtifactsObjDir)/LightCommandPackages</LightCommandObjDir>
<!-- Directory for the zipped up light command package -->
Expand Down Expand Up @@ -405,6 +409,27 @@
</ItemGroup>
</Target>

<Target Name="GenerateRuntimeAnalyzersNupkg"
DependsOnTargets="GenerateLayout;MsiTargetsSetupInputOutputs"
Condition=" '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64' And '$(DotNetBuild)' != 'true' "
Copy link
Member

Choose a reason for hiding this comment

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

@jjonescz I just saw this PR. Why did you add the DotNetBuild condition here? Shouldn't the package get produced in the product build? Note that starting with P4 we will ship the product from the VMR and this asset will be missing from the product then.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I will look into removing the condition.

Inputs="$(RuntimeAnalyzersLayoutDirectory)/**/*;
$(SdkRuntimeAnalyzersNuspecFile);
$(GenerateNupkgPowershellScript)"
Outputs="$(SdkRuntimeAnalyzersNupkgFile);$(SdkRuntimeAnalyzersSwrFile)">
<GenerateRuntimeAnalyzersSWR RuntimeAnalyzersLayoutDirectory="$(RuntimeAnalyzersLayoutDirectory)"
OutputFile="$(SdkRuntimeAnalyzersSwrFile)" />

<!-- Include the swr file in the nuget package for VS authoring -->
<Copy SourceFiles="$(SdkRuntimeAnalyzersSwrFile)" DestinationFolder="$(RuntimeAnalyzersLayoutDirectory)" />

<Exec Command="powershell -NoProfile -NoLogo $(GenerateNupkgPowershellScript) ^
'$(ArtifactsDir)' ^
'$(RuntimeAnalyzersLayoutDirectory.TrimEnd('\'))' ^
'$(FullNugetVersion)' ^
'$(SdkRuntimeAnalyzersNuspecFile)' ^
'$(SdkRuntimeAnalyzersNupkgFile)'" />
</Target>

<Target Name="GenerateMsis"
BeforeTargets="Pack"
DependsOnTargets="GenerateLayout;
Expand All @@ -416,6 +441,7 @@
GenerateSdkPlaceholderMsi;
GenerateToolsetNupkg;
GenerateTemplatesNupkgs;
GenerateSdkPlaceholderNupkg" />
GenerateSdkPlaceholderNupkg;
GenerateRuntimeAnalyzersNupkg" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>

<PropertyGroup>
<RuntimeAnalyzersLayoutDirectory>$(ArtifactsBinDir)$(Configuration)\RuntimeAnalyzers</RuntimeAnalyzersLayoutDirectory>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions src/Layout/redist/redist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<Import Project="targets\PublishDotnetWatch.targets" />
<Import Project="targets\GenerateLayout.targets" />
<Import Project="targets\OverlaySdkOnLKG.targets" Condition="'$(DotNetBuild)' != 'true'" />
<Import Project="targets\RuntimeAnalyzers.targets" />

<ItemGroup>
<PackageReference Include="NuGet.Build.Tasks" />
Expand Down
7 changes: 7 additions & 0 deletions src/Layout/redist/targets/GenerateLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@
DestinationFiles="@(MSBuildExtensionsContent->'$(OutputPath)\%(DeploymentSubpath)\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>

<Target Name="PublishRuntimeAnalyzers"
DependsOnTargets="GenerateRuntimeAnalyzers"
AfterTargets="OverlaySdkOnLKG">
<Copy SourceFiles="@(RuntimeAnalyzersContent)"
DestinationFiles="@(RuntimeAnalyzersContent->'$(ArtifactsBinDir)$(Configuration)\RuntimeAnalyzers\%(DeploymentSubpath)\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>

<Target Name="PublishNetSdks"
BeforeTargets="Build">
<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions src/Layout/redist/targets/RuntimeAnalyzers.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project>

<PropertyGroup>
<RuntimeAnalyzersSourceRoot>$(ArtifactsBinDir)redist\$(Configuration)\dotnet\</RuntimeAnalyzersSourceRoot>
<NetCoreRuntimeAnalyzersSubPath>packs\Microsoft.NetCore.App.Ref\*\analyzers</NetCoreRuntimeAnalyzersSubPath>
<WindowsDesktopRuntimeAnalyzersSubPath>packs\Microsoft.WindowsDesktop.App.Ref\*\analyzers</WindowsDesktopRuntimeAnalyzersSubPath>
<AspNetCoreRuntimeAnalyzersSubPath>packs\Microsoft.AspNetCore.App.Ref\*\analyzers</AspNetCoreRuntimeAnalyzersSubPath>
<SDKAnalyzersSubPath>sdk\*\Sdks\Microsoft.NET.Sdk\analyzers</SDKAnalyzersSubPath>
<WebSDKAnalyzersSubPath>sdk\*\Sdks\Microsoft.NET.Sdk.Web\analyzers</WebSDKAnalyzersSubPath>
</PropertyGroup>

<Target Name="GenerateRuntimeAnalyzers" AfterTargets="OverlaySdkOnLKG">

<ItemGroup>
<RuntimeAnalyzersContent Include="$(ArtifactsBinDir)Microsoft.Net.Sdk.AnalyzerRedirecting\$(Configuration)\net472\**\*.*" DeploymentSubpath="AnalyzerRedirecting"/>
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(NetCoreRuntimeAnalyzersSubPath)\**\*.*" DeploymentSubpath="NetCoreAnalyzers"/>
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(WindowsDesktopRuntimeAnalyzersSubPath)\**\*.*" DeploymentSubpath="WindowsDesktopAnalyzers"/>
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(AspNetCoreRuntimeAnalyzersSubPath)\**\*.*" DeploymentSubpath="AspNetCoreAnalyzers"/>
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(SDKAnalyzersSubPath)\**\*.*" DeploymentSubpath="SDKAnalyzers"/>
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(WebSDKAnalyzersSubPath)\**\*.*" DeploymentSubpath="WebSDKAnalyzers"/>
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Microsoft.VisualStudio.Shell;

namespace Microsoft.Net.Sdk.AnalyzerRedirecting;

[Guid("ef89a321-14da-4de4-8f71-9bf1feea15aa")]
public sealed class AnalyzerRedirectingPackage : AsyncPackage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<Project>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Nullable>enable</Nullable>

<IsShipping>false</IsShipping>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>

<!-- VSIX -->
<!-- We duplicate some logic like VsixVersion from arcade targets because they are imported only when using .NET Framework MSBuild,
but we want to build the VSIX in SDK's CI which is using Core MSBuild. See https://github.com/dotnet/arcade/issues/15617. -->
<VSSDKTargetPlatformRegRootSuffix>RoslynDev</VSSDKTargetPlatformRegRootSuffix>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
<IncludeDebugSymbolsInLocalVSIXDeployment>true</IncludeDebugSymbolsInLocalVSIXDeployment>
<IncludeCopyLocalReferencesInVSIXContainer>false</IncludeCopyLocalReferencesInVSIXContainer>
<VsixVersion Condition="'$(VsixVersion)' == ''">42.42.42.4242424</VsixVersion>
Copy link
Member

Choose a reason for hiding this comment

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

when is this ever set to a different value?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, good point, I thought arcade would set this, but maybe something is missing.

Copy link
Member

Choose a reason for hiding this comment

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

It does look like the arcade targets set this. src/Microsoft.DotNet.Arcade.Sdk/tools/VisualStudio.targets. I think it does set this to a default version if not specified. So maybe this line is not necessary?

Copy link
Member Author

@jjonescz jjonescz Mar 10, 2025

Choose a reason for hiding this comment

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

Ah, okay, I've remembered why this is needed. (I will add a comment.)

Arcade imports VisualStudio.targets only on .NET Framework MSBuild. But SDK's CI builds are using Core MSBuild. Filed also dotnet/arcade#15617.

when is this ever set to a different value?

And yes, it's set to a different value in production builds, see the target GetVsixVersion below in this file.

<DeployExtension Condition="'$(MSBuildRuntimeType)' == 'Core'">false</DeployExtension>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.VisualStudio.Sdk" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.Net.Sdk.AnalyzerRedirecting.Tests" />
</ItemGroup>

<Target Name="GetVsixVersion" Returns="$(VsixVersion)">
<PropertyGroup>
<VsixVersion Condition="'$(VersionSuffixDateStamp)' != ''">$(VersionPrefix).$(VersionSuffixDateStamp)$(VersionSuffixBuildOfTheDayPadded)</VsixVersion>
</PropertyGroup>
</Target>

<!-- Order matters here. VSSDK appends to PrepareForRunDependsOn but Microsoft.NET.Sdk overwrites it. See https://github.com/dotnet/msbuild/issues/2393. -->
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="Exists('$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets') and '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64'" />

</Project>
Loading