-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Create a transport package for VS and VS authoring for analyzers #42451
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
101 changes: 101 additions & 0 deletions
101
src/Installer/core-sdk-tasks/GenerateRuntimeAnalyzersSWR.cs
This file contains hidden or 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,101 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.DotNet.Cli.Build | ||
{ | ||
public class GenerateRuntimeAnalyzersSWR : Task | ||
{ | ||
[Required] | ||
public string RuntimeAnalyzersLayoutDirectory { get; set; } | ||
|
||
[Required] | ||
public string OutputFile { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
StringBuilder sb = new StringBuilder(SWR_HEADER); | ||
|
||
AddFolder(sb, | ||
@"AspNetCoreAnalyzers", | ||
@"SDK\AspNetCoreAnalyzers"); | ||
|
||
AddFolder(sb, | ||
@"NetCoreAnalyzers", | ||
@"SDK\NetCoreAnalyzers"); | ||
|
||
AddFolder(sb, | ||
@"WindowsDesktopAnalyzers", | ||
@"SDK\WindowsDesktopAnalyzers"); | ||
|
||
AddFolder(sb, | ||
@"SDKAnalyzers", | ||
@"SDK\SDKAnalyzers"); | ||
|
||
AddFolder(sb, | ||
@"WebSDKAnalyzers", | ||
@"SDK\WebSDKAnalyzers"); | ||
|
||
File.WriteAllText(OutputFile, sb.ToString()); | ||
|
||
return true; | ||
} | ||
|
||
private void AddFolder(StringBuilder sb, string relativeSourcePath, string swrInstallDir, bool ngenAssemblies = true) | ||
{ | ||
string sourceFolder = Path.Combine(RuntimeAnalyzersLayoutDirectory, relativeSourcePath); | ||
var files = Directory.GetFiles(sourceFolder) | ||
.Where(f => !Path.GetExtension(f).Equals(".pdb", StringComparison.OrdinalIgnoreCase) && !Path.GetExtension(f).Equals(".swr", StringComparison.OrdinalIgnoreCase)) | ||
.ToList(); | ||
if (files.Any(f => !Path.GetFileName(f).Equals("_._"))) | ||
{ | ||
sb.Append(@"folder ""InstallDir:\"); | ||
// remove the version number and everything until we get to the real analyzers folder | ||
Console.WriteLine(swrInstallDir); | ||
|
||
var startIndex = swrInstallDir.IndexOf("analyzers", StringComparison.OrdinalIgnoreCase); | ||
var endIndex = swrInstallDir.IndexOf("analyzers", startIndex + 1, StringComparison.OrdinalIgnoreCase); | ||
var tempinstalldir = swrInstallDir; | ||
if (startIndex >= 0 && endIndex >= 0) | ||
{ | ||
tempinstalldir = swrInstallDir.Remove(startIndex + 9, endIndex - startIndex ); | ||
} | ||
sb.Append(tempinstalldir); | ||
sb.AppendLine(@"\"""); | ||
|
||
foreach (var file in files) | ||
{ | ||
sb.Append(@" file source=""$(PkgVS_Redist_Common_Net_Core_SDK_RuntimeAnalyzers)\"); | ||
sb.Append(Path.Combine(relativeSourcePath, Path.GetFileName(file))); | ||
sb.Append('"'); | ||
|
||
if (ngenAssemblies && file.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
sb.Append(@" vs.file.ngenApplications=""[installDir]\Common7\IDE\vsn.exe"""); | ||
} | ||
|
||
sb.AppendLine(); | ||
} | ||
|
||
sb.AppendLine(); | ||
} | ||
|
||
foreach (var subfolder in Directory.GetDirectories(sourceFolder)) | ||
{ | ||
string subfolderName = Path.GetFileName(subfolder); | ||
string newRelativeSourcePath = Path.Combine(relativeSourcePath, subfolderName); | ||
string newSwrInstallDir = Path.Combine(swrInstallDir, subfolderName); | ||
|
||
// Don't propagate ngenAssemblies to subdirectories. | ||
AddFolder(sb, newRelativeSourcePath, newSwrInstallDir); | ||
} | ||
} | ||
|
||
readonly string SWR_HEADER = @"use vs | ||
|
||
package name=Microsoft.Net.Core.SDK.RuntimeAnalyzers | ||
version=$(ProductsBuildVersion) | ||
vs.package.internalRevision=$(PackageInternalRevision) | ||
|
||
"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../redist-installer/packaging/windows/VS.Redist.Common.Net.Core.SDK.RuntimeAnalyzers.nuspec
This file contains hidden or 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,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> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
7 changes: 7 additions & 0 deletions
7
src/Installer/redist-installer/targets/GenerateRuntimeAnalyzers.targets
This file contains hidden or 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,7 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<RuntimeAnalyzersLayoutDirectory>$(ArtifactsBinDir)$(Configuration)\RuntimeAnalyzers</RuntimeAnalyzersLayoutDirectory> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,23 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<RuntimeAnalyzersSourceRoot>$(ArtifactsBinDir)redist\$(Configuration)\dotnet\</RuntimeAnalyzersSourceRoot> | ||
<NetCoreRuntimeAnalyzersSubPath>packs\Microsoft.NetCore.App.Ref\9.*\analyzers</NetCoreRuntimeAnalyzersSubPath> | ||
<WindowsDesktopRuntimeAnalyzersSubPath>packs\Microsoft.WindowsDesktop.App.Ref\9.*\analyzers</WindowsDesktopRuntimeAnalyzersSubPath> | ||
<AspNetCoreRuntimeAnalyzersSubPath>packs\Microsoft.AspNetCore.App.Ref\9.*\analyzers</AspNetCoreRuntimeAnalyzersSubPath> | ||
<SDKAnalyzersSubPath>sdk\9.*\Sdks\Microsoft.NET.Sdk\Analyzers</SDKAnalyzersSubPath> | ||
<WebSDKAnalyzersSubPath>sdk\9.*\Sdks\Microsoft.NET.Sdk.Web\Analyzers</WebSDKAnalyzersSubPath> | ||
</PropertyGroup> | ||
|
||
<Target Name="GenerateRuntimeAnalyzers"> | ||
|
||
<ItemGroup> | ||
<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> |
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.
Should the target VS folder be something like
DotNetSdk
rather than justSDK
?