Stamp VS vsix and assembly with version from package.json

This commit is contained in:
Nick Guerrera 2021-04-09 17:35:08 -07:00
Родитель 0f2a5e9c48
Коммит dcc9fb1659
4 изменённых файлов: 42 добавлений и 15 удалений

Просмотреть файл

@ -0,0 +1,30 @@
<Project>
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets"
Condition="'$(VSToolsPath)' != '' and '$(MSBuildRuntimeType)' != 'Core'" />
<!--
VS SDK does not currently support building with dotnet build.
-->
<Target Name="WarnAboutDotnetBuildAndVsix"
Condition="'$(MSBuildRuntimeType)' == 'Core'"
AfterTargets="AfterBuild">
<Message
Importance="High"
Text="VSIX packaging skipped: not supported by `dotnet build`, use Visual Studio `msbuild` to package VSIX." />
</Target>
<!--
Stash debug source directory so deployed debug vsix can use it to find
and adl-server under development in source tree.
-->
<Target Name="WriteDebugSourceDirectory"
Condition="'$(Configuration)' == 'Debug'"
BeforeTargets="BeforeBuild">
<WriteLinesToFile File="$(IntermediateOutputPath)DebugSourceDirectory.txt"
Lines="$(MSBuildThisFileDirectory)"
WriteOnlyWhenDifferent="true"
Overwrite="true" />
</Target>
<Target Name="GetVersionForVsixManifest" Returns="$(Version)" />
</Project>

Просмотреть файл

@ -1,5 +1,4 @@
<Project>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<DebugType>Embedded</DebugType>
@ -11,16 +10,20 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningLevel>5</WarningLevel>
<Features>strict</Features>
<!-- Official build will pass in the real version from package.json, see scripts/build.js -->
<Version>42.42.42</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DeployExtension>false</DeployExtension>
<TargetVsixContainer>$(AssemblyName).vsix</TargetVsixContainer>
</PropertyGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<Content Include="$(IntermediateOutputPath)DebugSourceDirectory.txt" Link="DebugSourceDirectory.txt" Visible="False" />
</ItemGroup>
<ItemGroup>
<Content Include="LICENSE" Visible="False"/>
<Content Include="*.pkgdef" />
<Content Include="node_modules/adl-vscode/dist/adl.tmLanguage" Link="TextMate/adl.tmLanguage" />
<Content Include="$(IntermediateOutputPath)DebugSourceDirectory.txt" Link="DebugSourceDirectory.txt" Condition="'$(Configuration)' == 'Debug'" Visible="False" />
<Content Update="@(Content)" IncludeInVSIX="true" CopyToOutputDirectory="PreserveNewest" />
<None Include="*.vsixmanifest" />
<None Include="Properties\*.json" />
@ -29,12 +32,4 @@
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="16.0.206" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.10.23" />
</ItemGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != '' and '$(MSBuildRuntimeType)' != 'Core'" />
<Target Name="WarnAboutDotnetBuildAndVsix" Condition="'$(MSBuildRuntimeType)' == 'Core'" AfterTargets="AfterBuild">
<Message Importance="High" Text="VSIX packaging skipped: not supported by `dotnet build`, use Visual Studio `msbuild` to package VSIX." />
</Target>
<Target Name="WriteDebugSourceDirectory" Condition="'$(Configuration)' == 'Debug'" BeforeTargets="BeforeBuild">
<WriteLinesToFile File="$(IntermediateOutputPath)DebugSourceDirectory.txt" Lines="$(MSBuildThisFileDirectory)" WriteOnlyWhenDifferent="true" Overwrite="true" />
</Target>
</Project>

Просмотреть файл

@ -1,5 +1,6 @@
import { run } from "../../../eng/scripts/helpers.js";
import { join } from "path";
import { readFileSync } from "fs";
if (process.platform !== "win32") {
console.log("Skipping adl-vs build: not on Windows.");
@ -24,5 +25,6 @@ if (ignoreCommandNotFound && proc.error?.code === "ENOENT") {
process.exit(0);
}
const version = JSON.parse(readFileSync("package.json")).version;
const msbuild = join(proc.stdout.trim(), "MSBuild/Current/Bin/MSBuild.exe");
run(msbuild, ["/p:Configuration=Release", "/nologo"]);
run(msbuild, ["/p:Configuration=Release", `/p:Version=${version}`]);

Просмотреть файл

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="88b9492f-c019-492c-8aeb-f325a7e4cf23" Version="1.0" Language="en-US" Publisher="Microsoft" />
<Identity Id="88b9492f-c019-492c-8aeb-f325a7e4cf23" Version="|%CurrentProject%;GetVersionForVsixManifest|" Language="en-US" Publisher="Microsoft" />
<DisplayName>ADL Language Support</DisplayName>
<Description>ADL Language Support for Visual Studio</Description>
<MoreInfo>https://github.com/azure/adl</MoreInfo>
@ -15,8 +15,8 @@
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="File" Path="adl.pkgdef" />
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" Path="|Microsoft.Adl.VisualStudio;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" Path="|Microsoft.Adl.VisualStudio|" />
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" Path="|%CurrentProject%|" />
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,)" DisplayName="Visual Studio core editor" />