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

Add Razor language server telemetry to C# DevKit #9283

Merged
merged 19 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Razor.Slim.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"src\\Compiler\\tools\\Microsoft.CodeAnalysis.Razor.Tooling.Internal\\Microsoft.CodeAnalysis.Razor.Tooling.Internal.csproj",
"src\\Razor\\src\\Microsoft.CodeAnalysis.Razor.Workspaces\\Microsoft.CodeAnalysis.Razor.Workspaces.csproj",
"src\\Razor\\src\\Microsoft.CodeAnalysis.Remote.Razor\\Microsoft.CodeAnalysis.Remote.Razor.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.DevKit.Razor\\Microsoft.VisualStudio.DevKit.Razor.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.Editor.Razor\\Microsoft.VisualStudio.Editor.Razor.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.LanguageServices.Razor\\Microsoft.VisualStudio.LanguageServices.Razor.csproj",
Expand Down
11 changes: 11 additions & 0 deletions Razor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Razor.Diagnostics.Analyzers
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Razor.Diagnostics.Analyzers.Test", "src\Analyzers\Razor.Diagnostics.Analyzers.Test\Razor.Diagnostics.Analyzers.Test.csproj", "{167F1426-D9AE-49DF-B214-F00536DBC305}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.DevKit.Razor", "src\Razor\src\Microsoft.VisualStudio.DevKit.Razor\Microsoft.VisualStudio.DevKit.Razor.csproj", "{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -739,6 +741,14 @@ Global
{167F1426-D9AE-49DF-B214-F00536DBC305}.Release|Any CPU.Build.0 = Release|Any CPU
{167F1426-D9AE-49DF-B214-F00536DBC305}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{167F1426-D9AE-49DF-B214-F00536DBC305}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.Release|Any CPU.Build.0 = Release|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -820,6 +830,7 @@ Global
{BAFE178B-7AD4-41AE-A75D-9B920B9EA050} = {3AE210D1-C435-4693-BF79-2EF13ED554B9}
{45B207E2-DDB3-44F0-87C5-DEFB5A9534A5} = {4AA319E0-C81E-47CC-841A-6EFCB6784A1F}
{167F1426-D9AE-49DF-B214-F00536DBC305} = {4AA319E0-C81E-47CC-841A-6EFCB6784A1F}
{0F2D75D1-89AD-40A6-9F02-D45708AEA3EB} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0035341D-175A-4D05-95E6-F1C2785A1E26}
Expand Down
31 changes: 31 additions & 0 deletions eng/AfterSigning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,35 @@
<!-- Build a .zip file from each platform's directory and write it to 'artifacts' -->
<ZipDirectory SourceDirectory="%(LanguageServiceBinary.SourceDir)" DestinationFile="%(LanguageServiceBinary.ZipFile)" />
</Target>

<Target Name="_ZipDevKitTelemetryBinaries" AfterTargets="_ZipLanguageServerBinaries" Condition="'$(ArcadeBuildFromSource)' != 'true'">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We zip the files to publish to the CDN so we can consume the telemetry binaries on the vscode-csharp side.

<!-- This target is defined in eng/targets/Packaging.targets and included in every project. -->
<MSBuild Projects="$(RepoRoot)src\Razor\src\Microsoft.VisualStudio.DevKit.Razor\Microsoft.VisualStudio.DevKit.Razor.csproj"
Targets="_GetPackageVersionInfo"
SkipNonexistentProjects="false">
<Output TaskParameter="TargetOutputs" ItemName="_ResolvedPackageVersionInfo" />
</MSBuild>

<!-- Build a .zip file from each platform's directory and write it to 'artifacts' -->
<PropertyGroup>
<RidsPublishDir>$(ArtifactsDir)DevKitTelemetry\$(Configuration)\</RidsPublishDir>
<ZipOutputDir>$(RidsPublishDir)</ZipOutputDir>
<_DotNetPath>$(DOTNET_HOST_PATH)</_DotNetPath>
<_DotNetPath Condition="'$(_DotNetPath)' == ''">dotnet</_DotNetPath>
</PropertyGroup>

<ItemGroup>
<DevKitTelemetryBinaryDir Include="$([System.IO.Directory]::GetDirectories(&quot;$(RidsPublishDir)&quot;))" />
<DevKitTelemetryBinary Include="@(DevKitTelemetryBinaryDir)">
<SourceDir>%(DevKitTelemetryBinaryDir.Identity)</SourceDir>
<ZipFile>$(ZipOutputDir)DevKitTelemetry-%(DevKitTelemetryBinaryDir.Filename)-$(_PackageVersion).zip</ZipFile>
</DevKitTelemetryBinary>
</ItemGroup>

<MakeDir Directories="$(ZipOutputDir)" />
<Delete Files="%(DevKitTelemetryBinary.ZipFile)" />

<!-- Build a .zip file from each platform's directory and write it to 'artifacts' -->
<ZipDirectory SourceDirectory="%(DevKitTelemetryBinary.SourceDir)" DestinationFile="%(DevKitTelemetryBinary.ZipFile)" />
</Target>
</Project>
12 changes: 12 additions & 0 deletions eng/AfterSolutionBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,16 @@
Targets="PublishAllRids" />
</Target>

<Target Name="_PublishDevKitTelemetryRids" AfterTargets="Pack" Condition="'$(DotNetBuildFromSource)' != 'true'">
<PropertyGroup>
<DevKitTelemetryProject>$(MSBuildThisFileDirectory)..\src\Razor\src\Microsoft.VisualStudio.DevKit.Razor\Microsoft.VisualStudio.DevKit.Razor.csproj</DevKitTelemetryProject>
<RazorSolutionPath>$(MSBuildThisFileDirectory)..\Razor.sln</RazorSolutionPath>
</PropertyGroup>

<MSBuild Projects="$(RazorSolutionPath)"
Targets="Restore" />
<MSBuild Projects="$(DevKitTelemetryProject)"
Targets="PublishAllRids" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions eng/Publishing.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<!-- Prepare for _UpdatePublishItems target. -->
<_ItemsToPublish Include="$(ArtifactsPackagesDir)**\*.tgz" Condition="'$(OS)' == 'Windows_NT'" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is leftover from O# and is no longer needed

<_ItemsToPublish Include="$(ArtifactsDir)LanguageServer\**\*.zip" />
<_ItemsToPublish Include="$(ArtifactsDir)DevKitTelemetry\**\*.zip" />
</ItemGroup>

<Target Name="_UpdatePublishItems">
Expand All @@ -28,7 +28,7 @@
<!-- Packages can be built on all platforms, but are only published on Windows to avoid collisions from the other
platforms. This does not affect the SB intermediate package. -->
<ItemsToPushToBlobFeed Remove="$(ArtifactsDir)**\*.nupkg" Condition="'$(OS)' != 'Windows_NT' and '$(ArcadeBuildFromSource)' != 'true'" />

<ItemsToPushToBlobFeed Include="@(_ItemsToPublish)">
<IsShipping>false</IsShipping>
<ManifestArtifactData>ShipInstaller=dotnetcli;NonShipping=true</ManifestArtifactData>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<MicrosoftVisualStudioInteropPackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioInteropPackageVersion>
<MicrosoftInternalVisualStudioInteropPackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftInternalVisualStudioInteropPackageVersion>
<MicrosoftVisualStudioRpcContractsPackageVersion>17.7.9</MicrosoftVisualStudioRpcContractsPackageVersion>
<MicrosoftVisualStudioTelemetryVersion>17.7.8</MicrosoftVisualStudioTelemetryVersion>
<MicrosoftVisualStudioTelemetryVersion>17.8.138</MicrosoftVisualStudioTelemetryVersion>
<MicrosoftVisualStudioTextDataPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextDataPackageVersion>
<MicrosoftVisualStudioTextImplementationPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextImplementationPackageVersion>
<MicrosoftVisualStudioTextLogicPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextLogicPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) .NET Foundation. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This class is almost entirely taken from Roslyn with a few modifications to make it work for Razor

// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using Microsoft.VisualStudio.Composition;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Exports;

internal class CustomExportAssemblyLoader(string baseDirectory) : IAssemblyLoader
{
/// <summary>
/// Cache assemblies that are already loaded by AssemblyName comparison
/// </summary>
private readonly Dictionary<AssemblyName, Assembly> _loadedAssemblies = new(AssemblyNameComparer.Instance);

/// <summary>
/// Base directory to search for <see cref="Assembly.LoadFrom(string)"/> if initial load fails
/// </summary>
private readonly string _baseDirectory = baseDirectory;

public Assembly LoadAssembly(AssemblyName assemblyName)
{
Assembly? value;
lock (_loadedAssemblies)
{
_loadedAssemblies.TryGetValue(assemblyName, out value);
}

if (value == null)
{
// Attempt to load the assembly normally, but fall back to Assembly.LoadFrom in the base
// directory if the assembly load fails
try
{
value = Assembly.Load(assemblyName);
}
catch (FileNotFoundException) when (assemblyName.Name is not null)
{
var filePath = Path.Combine(_baseDirectory, assemblyName.Name)
+ (assemblyName.Name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
? ""
: ".dll");

value = Assembly.LoadFrom(filePath);

if (value is null)
{
throw;
}
}

lock (_loadedAssemblies)
{
_loadedAssemblies[assemblyName] = value;
return value;
}
}

return value;
}

public Assembly LoadAssembly(string assemblyFullName, string? codeBasePath)
{
var assemblyName = new AssemblyName(assemblyFullName);
return LoadAssembly(assemblyName);
}

private class AssemblyNameComparer : IEqualityComparer<AssemblyName>
{
public static AssemblyNameComparer Instance = new AssemblyNameComparer();

public bool Equals(AssemblyName? x, AssemblyName? y)
{
if (x == null && y == null)
{
return true;
}

if (x == null || y == null)
{
return false;
}

return x.Name == y.Name;
}

public int GetHashCode([DisallowNull] AssemblyName obj)
{
return obj.Name?.GetHashCode() ?? 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) .NET Foundation. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This class is almost entirely taken from Roslyn with a few modifications to make it work for Razor

// Licensed under the MIT license. See License.txt in the project root for license information.

#if !NET472

using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Composition;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Exports;

internal sealed class ExportProviderBuilder
{
public static async Task<ExportProvider> CreateExportProviderAsync(string extensionPath)
{
var baseDirectory = Path.GetDirectoryName(extensionPath);
var assemblyLoader = new CustomExportAssemblyLoader(baseDirectory!);
var resolver = new Resolver(assemblyLoader);

var discovery = PartDiscovery.Combine(
resolver,
new AttributedPartDiscovery(resolver, isNonPublicSupported: true), // "NuGet MEF" attributes (Microsoft.Composition)
new AttributedPartDiscoveryV1(resolver));

// TODO - we should likely cache the catalog so we don't have to rebuild it every time.
var parts = await discovery.CreatePartsAsync(new[] { extensionPath! }).ConfigureAwait(true);
var catalog = ComposableCatalog.Create(resolver)
.AddParts(parts)
.WithCompositionService(); // Makes an ICompositionService export available to MEF parts to import

// Assemble the parts into a valid graph.
var config = CompositionConfiguration.Create(catalog);

// Verify we have no errors.
config.ThrowOnErrors();

// Prepare an ExportProvider factory based on this graph.
var exportProviderFactory = config.CreateExportProviderFactory();

// Create an export provider, which represents a unique container of values.
// You can create as many of these as you want, but typically an app needs just one.
var exportProvider = exportProviderFactory.CreateExportProvider();

return exportProvider;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.DevKit.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Telemetry;

internal interface ITelemetryReporter
{
void InitializeSession(string telemetryLevel, string? sessionId, bool isDefaultSession);
IDisposable BeginBlock(string name, Severity severity);
IDisposable BeginBlock(string name, Severity severity, ImmutableDictionary<string, object?> values);
IDisposable TrackLspRequest(string lspMethodName, string lspServerName, Guid correlationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ private NoOpTelemetryReporter()
{
}

public void InitializeSession(string telemetryLevel, string? sessionId, bool isDefaultSession)
{
}

public void ReportEvent(string name, Severity severity)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFrameworks)</TargetFrameworks>
<PublishTargetFramework>net7.0</PublishTargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the language server assets for C# DevKit.</Description>
<EnableApiCheck>false</EnableApiCheck>
<RuntimeIdentifiers Condition="$([MSBuild]::IsOSPlatform('Windows'))">win-x64;win-x86;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux-x64;linux-musl-x64;linux-arm64;linux-musl-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::IsOSPlatform('OSX'))">osx-x64;osx-arm64</RuntimeIdentifiers>
<IsShippingPackage>false</IsShippingPackage>
<RemoveDevicePlatformSupport>true</RemoveDevicePlatformSupport>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Microsoft.VisualStudio.Editor.Razor\Telemetry\NullTelemetryScope.cs" Link="Telemetry\NullTelemetryScope.cs" />
<Compile Include="..\Microsoft.VisualStudio.Editor.Razor\Telemetry\TelemetryHelpers.cs" Link="Telemetry\TelemetryHelpers.cs" />
<Compile Include="..\Microsoft.VisualStudio.Editor.Razor\Telemetry\TelemetryReporter.cs" Link="Telemetry\TelemetryReporter.cs" />
<Compile Include="..\Microsoft.VisualStudio.Editor.Razor\Telemetry\TelemetryScope.cs" Link="Telemetry\TelemetryScope.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Telemetry" Version="$(MicrosoftVisualStudioTelemetryVersion)" />
</ItemGroup>

<ItemGroup>
<Content Include="$(RepositoryRoot)NOTICE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.ProjectEngineHost\Microsoft.AspNetCore.Razor.ProjectEngineHost.csproj" PrivateAssets="all" />
</ItemGroup>

<!--
Technique for publishing multiple RIDs from
https://github.com/dotnet/cli/issues/9221#issuecomment-387512008
Example usage:
dotnet msbuild -restore -t:PublishAllRids -p:Configuration=Release
-->
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>

<!-- Enable roll-forward to latest patch. This allows one restore operation
to apply to all of the self-contained publish operations. -->
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<RidsPublishDir>$(ArtifactsDir)DevKitTelemetry\$(Configuration)\</RidsPublishDir>
</PropertyGroup>

<Target Name="PublishAllRids">
<ItemGroup>
<!-- Transform RuntimeIdentifiers property to item -->
<RuntimeIdentifierForPublish Include="$(RuntimeIdentifiers)" />

<!-- Transform RuntimeIdentifierForPublish items to project items to pass to MSBuild task -->
<ProjectToPublish Include="@(RuntimeIdentifierForPublish->'$(MSBuildProjectFullPath)')">
<AdditionalProperties>RuntimeIdentifier=%(RuntimeIdentifierForPublish.Identity);PublishDir=$(RidsPublishDir)%(RuntimeIdentifierForPublish.Identity)\;TargetFramework=$(PublishTargetFramework)</AdditionalProperties>
</ProjectToPublish>

<ProjectToPublish_PlatformAgnostic Include="$(MSBuildProjectFullPath)">
<AdditionalProperties>PublishDir=$(RidsPublishDir)\PlatformAgnostic\;UseAppHost=false;TargetFramework=$(PublishTargetFramework)</AdditionalProperties>
</ProjectToPublish_PlatformAgnostic>
</ItemGroup>

<MSBuild Projects="@(ProjectToPublish)" Targets="Publish" BuildInParallel="false" />
<MSBuild Projects="@(ProjectToPublish_PlatformAgnostic)" Targets="Publish" BuildInParallel="false" Condition="'$(OS)' == 'WINDOWS_NT'" />
</Target>
</Project>
Loading