Skip to content

Commit 1ada0f9

Browse files
authored
Add analyzer redirecting VSIX (#42861)
1 parent eb63ff3 commit 1ada0f9

21 files changed

+542
-3
lines changed

Directory.Packages.props

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
<PackageVersion Include="Microsoft.TestPlatform.Build" Version="$(MicrosoftTestPlatformBuildPackageVersion)" />
6868
<PackageVersion Include="Microsoft.TestPlatform.CLI" Version="$(MicrosoftTestPlatformCLIPackageVersion)" />
6969
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.4.16" />
70+
<PackageVersion Include="Microsoft.VisualStudio.Sdk" Version="17.2.32505.173" />
71+
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.11.435" />
7072
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="$(MicrosoftVisualStudioSetupConfigurationInteropVersion)" />
7173
<PackageVersion Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.28" />
7274
<PackageVersion Include="Microsoft.Web.Deployment" Version="$(WebDeploymentPackageVersion)" />

NuGet.config

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<add key="dotnet-tools-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-transport/nuget/v3/index.json" />
2626
<add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" />
2727
<add key="dotnet-libraries-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries-transport/nuget/v3/index.json" />
28+
<add key="vssdk" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json" />
29+
<add key="vssdk-archived" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk-archived/nuget/v3/index.json" />
2830
<add key="vs-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json" />
2931
<!-- Used for Rich Navigation indexing task -->
3032
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />

eng/Signing.props

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
<FileSignInfo Include="MessagePack.Annotations.dll" CertificateName="$(ExternalCertificateId)" />
6161
<FileSignInfo Include="MessagePack.dll" CertificateName="$(ExternalCertificateId)" />
6262
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="$(ExternalCertificateId)" />
63-
<FileSignInfo Include="StreamJsonRpc.dll" CertificateName="$(ExternalCertificateId)" />
6463
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="$(ExternalCertificateId)" />
6564
<FileSignInfo Include="CommandLine.dll" CertificateName="$(ExternalCertificateId)" />
6665
<FileSignInfo Include="FluentAssertions.dll" CertificateName="$(ExternalCertificateId)" />
@@ -74,6 +73,10 @@
7473
<FileSignInfo Include="Valleysoft.DockerCredsProvider.dll" CertificateName="$(ExternalCertificateId)" />
7574
</ItemGroup>
7675

76+
<ItemGroup>
77+
<FileSignInfo Include="StreamJsonRpc.dll" CertificateName="MicrosoftSHA2" />
78+
</ItemGroup>
79+
7780
<!-- Filter out any test packages from ItemsToSign -->
7881
<ItemGroup>
7982
<ItemsToSign Remove="$(ArtifactsPackagesDir)**\*tests*.nupkg" />

eng/Versions.props

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
compiler API targeted by analyzer assemblies. This is mostly an issue on source-build as
2727
in that build mode analyzer assemblies always target the live compiler API. -->
2828
<UsingToolMicrosoftNetCompilers Condition="'$(DotNetBuildSourceOnly)' == 'true'">true</UsingToolMicrosoftNetCompilers>
29+
<UsingToolVSSDK>true</UsingToolVSSDK>
2930
<MicrosoftIORedistPackageVersion>6.0.1</MicrosoftIORedistPackageVersion>
3031
<FlagNetStandard1XDependencies Condition="'$(DotNetBuildSourceOnly)' == 'true'">true</FlagNetStandard1XDependencies>
3132
<!-- This property is only used in the dotnet test integration tests. -->

sdk.sln

+14
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.HotReload.
521521
EndProject
522522
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}"
523523
EndProject
524+
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}"
525+
EndProject
526+
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}"
527+
EndProject
524528
Global
525529
GlobalSection(SolutionConfigurationPlatforms) = preSolution
526530
Debug|Any CPU = Debug|Any CPU
@@ -987,6 +991,14 @@ Global
987991
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748}.Debug|Any CPU.Build.0 = Debug|Any CPU
988992
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748}.Release|Any CPU.ActiveCfg = Release|Any CPU
989993
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748}.Release|Any CPU.Build.0 = Release|Any CPU
994+
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
995+
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
996+
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
997+
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1}.Release|Any CPU.Build.0 = Release|Any CPU
998+
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
999+
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Debug|Any CPU.Build.0 = Debug|Any CPU
1000+
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Release|Any CPU.ActiveCfg = Release|Any CPU
1001+
{234BE46E-4AD6-485C-B0D3-E704EF504312}.Release|Any CPU.Build.0 = Release|Any CPU
9901002
EndGlobalSection
9911003
GlobalSection(SolutionProperties) = preSolution
9921004
HideSolutionNode = FALSE
@@ -1169,6 +1181,8 @@ Global
11691181
{FA3C7F91-42A2-45AD-897C-F646B081016C} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
11701182
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
11711183
{0762B436-F4B0-4008-9097-BB5FF6BD84AF} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
1184+
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
1185+
{234BE46E-4AD6-485C-B0D3-E704EF504312} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
11721186
EndGlobalSection
11731187
GlobalSection(ExtensibilityGlobals) = postSolution
11741188
SolutionGuid = {FB8F26CE-4DE6-433F-B32A-79183020BBD6}

src/Installer/redist-installer/Directory.Build.targets

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<Import Project="targets\GenerateBundledVersions.targets" />
3939
<Import Project="targets\Crossgen.targets" />
4040
<Import Project="targets\GenerateLayout.targets" />
41+
<Import Project="targets\GenerateRuntimeAnalyzers.targets" />
4142
<Import Project="targets\Badge.targets" Condition="'$(PgoInstrument)' != 'true'" />
4243
<Import Project="targets\GenerateArchives.targets" />
4344

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
2+
<metadata>
3+
<id>VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers</id>
4+
<version>1.0.0</version>
5+
<title>VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers</title>
6+
<authors>Microsoft</authors>
7+
<owners>Microsoft</owners>
8+
<licenseUrl>https://www.microsoft.com/net/dotnet_library_license.htm</licenseUrl>
9+
<projectUrl>https://github.com/dotnet/sdk</projectUrl>
10+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
11+
<description>Analyzers and generators from the runtime and SDK for VS insertion</description>
12+
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
13+
</metadata>
14+
<files>
15+
<file src="$PAYLOAD_FILES$\**\*" />
16+
</files>
17+
</package>

src/Installer/redist-installer/targets/GenerateMSIs.targets

+27-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<SdkPlaceholderInstallerNuspecFile>$(SdkPkgSourcesRootDirectory)/VS.Redist.Common.NetCore.SdkPlaceholder.nuspec</SdkPlaceholderInstallerNuspecFile>
2828
<SdkPlaceholderInstallerNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.NetCore.SdkPlaceholder.$(Architecture).$(FullNugetVersion).nupkg</SdkPlaceholderInstallerNupkgFile>
2929

30+
<SdkRuntimeAnalyzersNuspecFile>$(SdkPkgSourcesRootDirectory)/VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.nuspec</SdkRuntimeAnalyzersNuspecFile>
31+
<SdkRuntimeAnalyzersNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.$(FullNugetVersion).nupkg</SdkRuntimeAnalyzersNupkgFile>
32+
<SdkRuntimeAnalyzersSwrFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.swr</SdkRuntimeAnalyzersSwrFile>
33+
3034
<!-- Temp directory for light command layouts -->
3135
<LightCommandObjDir>$(ArtifactsObjDir)/LightCommandPackages</LightCommandObjDir>
3236
<!-- Directory for the zipped up light command package -->
@@ -405,6 +409,27 @@
405409
</ItemGroup>
406410
</Target>
407411

412+
<Target Name="GenerateRuntimeAnalyzersNupkg"
413+
DependsOnTargets="GenerateLayout;MsiTargetsSetupInputOutputs"
414+
Condition=" '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64' And '$(DotNetBuild)' != 'true' "
415+
Inputs="$(RuntimeAnalyzersLayoutDirectory)/**/*;
416+
$(SdkRuntimeAnalyzersNuspecFile);
417+
$(GenerateNupkgPowershellScript)"
418+
Outputs="$(SdkRuntimeAnalyzersNupkgFile);$(SdkRuntimeAnalyzersSwrFile)">
419+
<GenerateRuntimeAnalyzersSWR RuntimeAnalyzersLayoutDirectory="$(RuntimeAnalyzersLayoutDirectory)"
420+
OutputFile="$(SdkRuntimeAnalyzersSwrFile)" />
421+
422+
<!-- Include the swr file in the nuget package for VS authoring -->
423+
<Copy SourceFiles="$(SdkRuntimeAnalyzersSwrFile)" DestinationFolder="$(RuntimeAnalyzersLayoutDirectory)" />
424+
425+
<Exec Command="powershell -NoProfile -NoLogo $(GenerateNupkgPowershellScript) ^
426+
'$(ArtifactsDir)' ^
427+
'$(RuntimeAnalyzersLayoutDirectory.TrimEnd('\'))' ^
428+
'$(FullNugetVersion)' ^
429+
'$(SdkRuntimeAnalyzersNuspecFile)' ^
430+
'$(SdkRuntimeAnalyzersNupkgFile)'" />
431+
</Target>
432+
408433
<Target Name="GenerateMsis"
409434
BeforeTargets="Pack"
410435
DependsOnTargets="GenerateLayout;
@@ -416,6 +441,7 @@
416441
GenerateSdkPlaceholderMsi;
417442
GenerateToolsetNupkg;
418443
GenerateTemplatesNupkgs;
419-
GenerateSdkPlaceholderNupkg" />
444+
GenerateSdkPlaceholderNupkg;
445+
GenerateRuntimeAnalyzersNupkg" />
420446

421447
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<RuntimeAnalyzersLayoutDirectory>$(ArtifactsBinDir)$(Configuration)\RuntimeAnalyzers</RuntimeAnalyzersLayoutDirectory>
5+
</PropertyGroup>
6+
7+
</Project>

src/Layout/redist/redist.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<Import Project="targets\PublishDotnetWatch.targets" />
2424
<Import Project="targets\GenerateLayout.targets" />
2525
<Import Project="targets\OverlaySdkOnLKG.targets" Condition="'$(DotNetBuild)' != 'true'" />
26+
<Import Project="targets\RuntimeAnalyzers.targets" />
2627

2728
<ItemGroup>
2829
<PackageReference Include="NuGet.Build.Tasks" />

src/Layout/redist/targets/GenerateLayout.targets

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@
141141
DestinationFiles="@(MSBuildExtensionsContent->'$(OutputPath)\%(DeploymentSubpath)\%(RecursiveDir)%(Filename)%(Extension)')" />
142142
</Target>
143143

144+
<Target Name="PublishRuntimeAnalyzers"
145+
DependsOnTargets="GenerateRuntimeAnalyzers"
146+
AfterTargets="OverlaySdkOnLKG">
147+
<Copy SourceFiles="@(RuntimeAnalyzersContent)"
148+
DestinationFiles="@(RuntimeAnalyzersContent->'$(ArtifactsBinDir)$(Configuration)\RuntimeAnalyzers\%(DeploymentSubpath)\%(RecursiveDir)%(Filename)%(Extension)')" />
149+
</Target>
150+
144151
<Target Name="PublishNetSdks"
145152
BeforeTargets="Build">
146153
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<RuntimeAnalyzersSourceRoot>$(ArtifactsBinDir)redist\$(Configuration)\dotnet\</RuntimeAnalyzersSourceRoot>
5+
<NetCoreRuntimeAnalyzersSubPath>packs\Microsoft.NetCore.App.Ref\*\analyzers</NetCoreRuntimeAnalyzersSubPath>
6+
<WindowsDesktopRuntimeAnalyzersSubPath>packs\Microsoft.WindowsDesktop.App.Ref\*\analyzers</WindowsDesktopRuntimeAnalyzersSubPath>
7+
<AspNetCoreRuntimeAnalyzersSubPath>packs\Microsoft.AspNetCore.App.Ref\*\analyzers</AspNetCoreRuntimeAnalyzersSubPath>
8+
<SDKAnalyzersSubPath>sdk\*\Sdks\Microsoft.NET.Sdk\analyzers</SDKAnalyzersSubPath>
9+
<WebSDKAnalyzersSubPath>sdk\*\Sdks\Microsoft.NET.Sdk.Web\analyzers</WebSDKAnalyzersSubPath>
10+
</PropertyGroup>
11+
12+
<Target Name="GenerateRuntimeAnalyzers" AfterTargets="OverlaySdkOnLKG">
13+
14+
<ItemGroup>
15+
<RuntimeAnalyzersContent Include="$(ArtifactsBinDir)Microsoft.Net.Sdk.AnalyzerRedirecting\$(Configuration)\net472\**\*.*" DeploymentSubpath="AnalyzerRedirecting"/>
16+
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(NetCoreRuntimeAnalyzersSubPath)\**\*.*" DeploymentSubpath="NetCoreAnalyzers"/>
17+
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(WindowsDesktopRuntimeAnalyzersSubPath)\**\*.*" DeploymentSubpath="WindowsDesktopAnalyzers"/>
18+
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(AspNetCoreRuntimeAnalyzersSubPath)\**\*.*" DeploymentSubpath="AspNetCoreAnalyzers"/>
19+
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(SDKAnalyzersSubPath)\**\*.*" DeploymentSubpath="SDKAnalyzers"/>
20+
<RuntimeAnalyzersContent Include="$(RuntimeAnalyzersSourceRoot)$(WebSDKAnalyzersSubPath)\**\*.*" DeploymentSubpath="WebSDKAnalyzers"/>
21+
</ItemGroup>
22+
</Target>
23+
24+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Microsoft.VisualStudio.Shell;
2+
3+
namespace Microsoft.Net.Sdk.AnalyzerRedirecting;
4+
5+
[Guid("ef89a321-14da-4de4-8f71-9bf1feea15aa")]
6+
public sealed class AnalyzerRedirectingPackage : AsyncPackage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<Project>
2+
3+
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
4+
5+
<PropertyGroup>
6+
<TargetFramework>net472</TargetFramework>
7+
<Nullable>enable</Nullable>
8+
9+
<IsShipping>false</IsShipping>
10+
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
11+
12+
<!-- VSIX -->
13+
<!-- We duplicate some logic like VsixVersion from arcade targets because they are imported only when using .NET Framework MSBuild,
14+
but we want to build the VSIX in SDK's CI which is using Core MSBuild. See https://github.com/dotnet/arcade/issues/15617. -->
15+
<VSSDKTargetPlatformRegRootSuffix>RoslynDev</VSSDKTargetPlatformRegRootSuffix>
16+
<GeneratePkgDefFile>true</GeneratePkgDefFile>
17+
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
18+
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
19+
<IncludeDebugSymbolsInLocalVSIXDeployment>true</IncludeDebugSymbolsInLocalVSIXDeployment>
20+
<IncludeCopyLocalReferencesInVSIXContainer>false</IncludeCopyLocalReferencesInVSIXContainer>
21+
<VsixVersion Condition="'$(VsixVersion)' == ''">42.42.42.4242424</VsixVersion>
22+
<DeployExtension Condition="'$(MSBuildRuntimeType)' == 'Core'">false</DeployExtension>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
27+
<PackageReference Include="Microsoft.VisualStudio.Sdk" />
28+
<PackageReference Include="Microsoft.VSSDK.BuildTools" PrivateAssets="all" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<InternalsVisibleTo Include="Microsoft.Net.Sdk.AnalyzerRedirecting.Tests" />
33+
</ItemGroup>
34+
35+
<Target Name="GetVsixVersion" Returns="$(VsixVersion)">
36+
<PropertyGroup>
37+
<VsixVersion Condition="'$(VersionSuffixDateStamp)' != ''">$(VersionPrefix).$(VersionSuffixDateStamp)$(VersionSuffixBuildOfTheDayPadded)</VsixVersion>
38+
</PropertyGroup>
39+
</Target>
40+
41+
<!-- Order matters here. VSSDK appends to PrepareForRunDependsOn but Microsoft.NET.Sdk overwrites it. See https://github.com/dotnet/msbuild/issues/2393. -->
42+
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
43+
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="Exists('$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets') and '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64'" />
44+
45+
</Project>

0 commit comments

Comments
 (0)