2018-12-02 03:25:55 +03:00
<Project>
2019-05-29 23:06:38 +03:00
<Target
Name="GenerateMPack"
AfterTargets="Build"
DependsOnTargets="_MPackWriteAddinInfo"
Condition="'$(IsMPackProject)'=='true' and '$(TargetFramework)'!='' and ('$(DotNetBuildFromSource)' != 'true' or '$(ExcludeFromSourceBuild)' != 'true')">
2018-12-02 03:25:55 +03:00
<!--
In our case the mpack archive requires the following:
1. An addin.info
2. An addin binary (Microsoft.VisualStudio.Mac.RazorAddin.dll)
a. _Manifest.addin.xml embedded
2019-05-29 23:06:38 +03:00
b. Addin assembly attributes for metadata
2018-12-02 03:25:55 +03:00
3. All language service binaries
-->
<PropertyGroup>
2020-04-09 05:03:31 +03:00
<MPackVersion Condition="'$(MPackVersion)' == '' And '$(TF_BUILD)' == 'true'">-$(BUILD_BUILDNUMBER)-$(BUILD_SOURCEVERSION.Substring(0, 8))-$(BUILD_SOURCEBRANCHNAME)</MPackVersion>
2020-05-18 21:08:37 +03:00
<MPackName>Razor$(MPackVersion)</MPackName>
2018-12-02 03:25:55 +03:00
<MPackFileName>$(MPackName).mpack</MPackFileName>
<MPackOutputPath>$(ArtifactsMPackDir)$(MPackFileName)</MPackOutputPath>
</PropertyGroup>
<ItemGroup>
<MPackFile Include="$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).dll" />
2020-04-09 04:21:17 +03:00
<MPackFile Include="$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).pdb" Condition="Exists('$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).pdb')" />
2018-12-02 03:25:55 +03:00
</ItemGroup>
<RemoveDir Directories="$(IntermediateOutputPath)MPack\" />
<MakeDir Directories="$(IntermediateOutputPath);$(IntermediateOutputPath)MPack\" />
<Copy SourceFiles="@(MPackFile)" DestinationFolder="$(IntermediateOutputPath)MPack\" />
2019-05-29 23:06:38 +03:00
2018-12-02 03:25:55 +03:00
<MakeDir Directories="$(ArtifactsMPackDir)" />
2019-05-29 23:06:38 +03:00
<ZipDirectory
SourceDirectory="$(IntermediateOutputPath)MPack\"
DestinationFile="$(MPackOutputPath)"
2018-12-02 03:25:55 +03:00
Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(MPackOutputPath)" />
</ItemGroup>
</Target>
<Target Name="_MPackWriteAddinInfo">
<PropertyGroup>
2019-05-29 23:06:38 +03:00
<MPackManifest>$(AddinDirectory)Properties\_Manifest.addin.xml</MPackManifest>
2018-12-02 03:25:55 +03:00
<AddinInfoFilePath>$(IntermediateOutputPath)addin.info</AddinInfoFilePath>
</PropertyGroup>
<!-- We need to resolve the language service assemblies to generate an addin.info for the mpack -->
<XmlPeek XmlInputPath="$(MPackManifest)" Query="/ExtensionModel/Runtime/Import/@assembly">
<Output TaskParameter="Result" ItemName="MPackAssemblyNames" />
</XmlPeek>
<!-- We need to resolve the addin dependencies to generate an addin.info for the mpack -->
<XmlPeek XmlInputPath="$(MPackManifest)" Query="/ExtensionModel/Dependencies/Addin">
<Output TaskParameter="Result" ItemName="AddinDependencies" />
</XmlPeek>
<ItemGroup>
<AddinInfoLine Include="<Addin id="$(AddinId)" namespace="$(AddinNamespace)" version="$(AddinVersion)" name="$(AddinDetailedName)" author="$(Authors)" description="$(Description)" category="$(AddinCategory)">" />
<AddinInfoLine Include=" <Runtime>" />
<AddinInfoLine Include=" <Import assembly="%(MPackAssemblyNames.Identity)" />" />
<AddinInfoLine Include=" <Import assembly="$(AddinName).dll" />" />
<AddinInfoLine Include=" </Runtime>" />
<AddinInfoLine Include=" <Dependencies>" />
<AddinInfoLine Include=" %(AddinDependencies.Identity)" />
<AddinInfoLine Include=" </Dependencies>" />
<AddinInfoLine Include="</Addin>" />
</ItemGroup>
<WriteLinesToFile File="$(AddinInfoFilePath)" Lines="@(AddinInfoLine)" Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(AddinInfoFilePath)" />
<MPackFile Include="$(AddinInfoFilePath)" />
</ItemGroup>
</Target>
</Project>