razor-tooling/eng/MPack.targets

80 строки
3.5 KiB
XML

<Project>
<Target
Name="GenerateMPack"
AfterTargets="Build"
DependsOnTargets="_MPackWriteAddinInfo"
Condition="'$(IsMPackProject)'=='true' and '$(TargetFramework)'!='' and ('$(DotNetBuildFromSource)' != 'true' or '$(ExcludeFromSourceBuild)' != 'true')">
<!--
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
b. Addin assembly attributes for metadata
3. All language service binaries
-->
<PropertyGroup>
<MPackName>$(AddinName)_$(AddinVersion)</MPackName>
<MPackFileName>$(MPackName).mpack</MPackFileName>
<MPackOutputPath>$(ArtifactsMPackDir)$(MPackFileName)</MPackOutputPath>
</PropertyGroup>
<ItemGroup>
<MPackFile Include="$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).dll" />
<MPackFile Include="$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).pdb" />
</ItemGroup>
<RemoveDir Directories="$(IntermediateOutputPath)MPack\" />
<MakeDir Directories="$(IntermediateOutputPath);$(IntermediateOutputPath)MPack\" />
<Copy SourceFiles="@(MPackFile)" DestinationFolder="$(IntermediateOutputPath)MPack\" />
<MakeDir Directories="$(ArtifactsMPackDir)" />
<ZipDirectory
SourceDirectory="$(IntermediateOutputPath)MPack\"
DestinationFile="$(MPackOutputPath)"
Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(MPackOutputPath)" />
</ItemGroup>
</Target>
<Target Name="_MPackWriteAddinInfo">
<PropertyGroup>
<MPackManifest>$(AddinDirectory)Properties\_Manifest.addin.xml</MPackManifest>
<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="&lt;Addin id=&quot;$(AddinId)&quot; namespace=&quot;$(AddinNamespace)&quot; version=&quot;$(AddinVersion)&quot; name=&quot;$(AddinDetailedName)&quot; author=&quot;$(Authors)&quot; description=&quot;$(Description)&quot; category=&quot;$(AddinCategory)&quot;&gt;" />
<AddinInfoLine Include=" &lt;Runtime&gt;" />
<AddinInfoLine Include=" &lt;Import assembly=&quot;%(MPackAssemblyNames.Identity)&quot; /&gt;" />
<AddinInfoLine Include=" &lt;Import assembly=&quot;$(AddinName).dll&quot; /&gt;" />
<AddinInfoLine Include=" &lt;/Runtime&gt;" />
<AddinInfoLine Include=" &lt;Dependencies&gt;" />
<AddinInfoLine Include=" %(AddinDependencies.Identity)" />
<AddinInfoLine Include=" &lt;/Dependencies&gt;" />
<AddinInfoLine Include="&lt;/Addin&gt;" />
</ItemGroup>
<WriteLinesToFile File="$(AddinInfoFilePath)" Lines="@(AddinInfoLine)" Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(AddinInfoFilePath)" />
<MPackFile Include="$(AddinInfoFilePath)" />
</ItemGroup>
</Target>
</Project>