Skip to content

Commit

Permalink
Publish rzls as a nuget package for vs-code (#10453)
Browse files Browse the repository at this point in the history
The majority of this was just copied from the way Roslyn packages their language server. Publish each of our RIDs for rzls as nuget packages instead of zipping them for the cdn.
  • Loading branch information
ryzngard committed Jun 12, 2024
1 parent 0b7c3a0 commit 74bed8e
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 202 deletions.
63 changes: 0 additions & 63 deletions eng/AfterSigning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -38,67 +38,4 @@
<FileWrites Include="$(_DependentAssemblyVersionsFile)"/>
</ItemGroup>
</Target>

<Target Name="_ZipLanguageServerBinaries" AfterTargets="Pack" Condition="'$(ArcadeBuildFromSource)' != 'true'">
<!-- This target is defined in eng/targets/Packaging.targets and included in every project. -->
<MSBuild Projects="$(RepoRoot)src\Razor\src\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.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)LanguageServer\$(Configuration)\</RidsPublishDir>
<ZipOutputDir>$(RidsPublishDir)</ZipOutputDir>
<_PackageVersion>@(_ResolvedPackageVersionInfo->'%(PackageVersion)')</_PackageVersion>
<_DotNetPath>$(DOTNET_HOST_PATH)</_DotNetPath>
<_DotNetPath Condition="'$(_DotNetPath)' == ''">dotnet</_DotNetPath>
</PropertyGroup>

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

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

<!-- 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'">
<!-- 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>
30 changes: 0 additions & 30 deletions eng/AfterSolutionBuild.targets

This file was deleted.

4 changes: 3 additions & 1 deletion eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="MessagePack.Annotations.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="MessagePack.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="Humanizer.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="ICSharpCode.Decompiler.dll" CertificateName="3PartySHA2" />
</ItemGroup>

</Project>
</Project>
21 changes: 21 additions & 0 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
{
"feeds": {
"vs-impl": "https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json"
},
"packages": {
"default": {
"rzls": "vs-impl",
"rzls.alpine-arm64": "vs-impl",
"rzls.alpine-x64": "vs-impl",
"rzls.linux-arm64": "vs-impl",
"rzls.linux-x64": "vs-impl",
"rzls.linux-musl-x64": "vs-impl",
"rzls.linux-musl-arm64": "vs-impl",
"rzls.neutral": "vs-impl",
"rzls.osx-arm64": "vs-impl",
"rzls.osx-x64": "vs-impl",
"rzls.win-arm64": "vs-impl",
"rzls.win-x64": "vs-impl",
"rzls.win-x86": "vs-impl",
"Microsoft.VisualStudio.DevKit.Razor": "vs-impl"
}
},
"branches": {
"main": {
"nugetKind": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFrameworks)</TargetFrameworks>
<PublishTargetFramework>net8.0</PublishTargetFramework>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<OutputType>Library</OutputType>
<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>
<IsShippingPackage>false</IsShippingPackage>
<RemoveDevicePlatformSupport>true</RemoveDevicePlatformSupport>
</PropertyGroup>

<!--
In a vertical build, we'll only publish for the RID of the vertical.
In a non-vertical build, we'll publish for all RIDs of the OS we are building on (to reduce the number of CI jobs).
-->
<PropertyGroup Condition="'$(DotNetBuild)' != 'true'">
<RuntimeIdentifiers Condition="$([MSBuild]::IsOSPlatform('Windows'))">win-x64;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>
</PropertyGroup>
<IsShippingPackage>true</IsShippingPackage>
<IsPackable>true</IsPackable>

<PropertyGroup Condition="'$(DotNetBuild)' == 'true'">
<RuntimeIdentifiers>$(TargetRid)</RuntimeIdentifiers>
<RuntimeIdentifier>$(TargetRid)</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<RidSpecificPublishNoBuildProperty>NoBuild=true</RidSpecificPublishNoBuildProperty>
<!-- This is not a standard nuget package and only consumed by the extension build. We don't care if the folder structure doesn't match what nuget expects. -->
<NoWarn>$(NoWarn);NU5100</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -37,6 +22,10 @@
<PackageReference Include="Microsoft.VisualStudio.Telemetry" />
</ItemGroup>

<ItemGroup>
<Content Include="$(TargetPath)" Pack="true" PackagePath="content" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<Content Include="$(RepositoryRoot)NOTICE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand All @@ -46,38 +35,4 @@
<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>_IsPublishing=true;$(RidSpecificPublishNoBuildProperty);RuntimeIdentifier=%(RuntimeIdentifierForPublish.Identity);PublishDir=$(RidsPublishDir)%(RuntimeIdentifierForPublish.Identity)\;TargetFramework=$(PublishTargetFramework);SelfContained=false</AdditionalProperties>
</ProjectToPublish>

<ProjectToPublish_PlatformAgnostic Include="$(MSBuildProjectFullPath)">
<AdditionalProperties>_IsPublishing=true;NoBuild=true;PublishDir=$(RidsPublishDir)\PlatformAgnostic\;UseAppHost=false;TargetFramework=$(PublishTargetFramework);SelfContained=false</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>
32 changes: 32 additions & 0 deletions src/Razor/src/rzls/PublishAllRids.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project>
<!-- We are defining our own Pack target, so opt out of the SDK version. -->
<PropertyGroup>
<ImportNuGetBuildTasksPackTargetsFromSdk>false</ImportNuGetBuildTasksPackTargetsFromSdk>
<_RazorPublishReadyToRun>false</_RazorPublishReadyToRun>
<_RazorPublishReadyToRun Condition="'$(Configuration)' == 'Release'">true</_RazorPublishReadyToRun>
</PropertyGroup>

<Target Name="Pack">
<!--
We have to run restore first with the PublishReadyToRun flag set to true to ensure that the correct crossgen packages get restored.
See https://github.com/dotnet/sdk/issues/20701
We also pass the RestoreUseStaticGraphEvaluation=false flag to workaround a long path issue when calling the restore target.
See https://github.com/NuGet/Home/issues/11968
-->
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Restore" Properties="PublishReadyToRun=$(_RazorPublishReadyToRun);RestoreUseStaticGraphEvaluation=false" />

<ItemGroup>
<!-- Transform RuntimeIdentifiers property to item -->
<RuntimeIdentifierForPack Include="$(RuntimeIdentifiers)" />
<RuntimeIdentifierForPack Include="neutral" />

<!-- Transform RuntimeIdentifierForPublish items to project items to pass to MSBuild task -->
<ProjectToPublish Include="@(RuntimeIdentifierForPack->'$(MSBuildProjectFullPath)')">
<AdditionalProperties>PackRuntimeIdentifier=%(RuntimeIdentifierForPack.Identity)</AdditionalProperties>
</ProjectToPublish>
</ItemGroup>

<MSBuild Projects="@(ProjectToPublish)" Targets="Pack" BuildInParallel="true" />
</Target>
</Project>
Loading

0 comments on commit 74bed8e

Please sign in to comment.