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

Vs insertion Sbom generation (Roslyn,fSharp) #9629

Merged
merged 11 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,14 @@
<GenerateSbom Condition="'$(GenerateSbom)' == ''">false</GenerateSbom>
</PropertyGroup>

<Target Name ="GenerateSbomForVSInsertion"
Condition="'$(GenerateSbom)' != 'false'">
<Message Text="Generating SBOM manifest" Importance="high"/>
<ItemGroup>
<VsixFile Include="$(ArtifactsDir)VSSetup\$(Configuration)\Insertion\*.vsix"></VsixFile>
<VsixFile Include="$(ArtifactsDir)VSSetup\$(Configuration)\Insertion\*.exe"></VsixFile>
</ItemGroup>
<MakeDir Directories="$(ArtifactsDir)sbom;$(ArtifactsDir)sbom\%(VsixFile.Filename);$(ArtifactsDir)Vsix;$(ArtifactsDir)Vsix\Unpacked\%(VsixFile.Filename)"/>

<Unzip
SourceFiles="@(VsixFile)"
DestinationFolder="$(ArtifactsDir)Vsix\Unpacked\%(VsixFile.Filename)"
OverwriteReadOnlyFiles="true"/>

<Exec Command = "$(DotNetTool) $(NUGET_PACKAGES)microsoft.manifesttool.crossplatform\$(MicrosoftManifestToolCrossPlatformVersion)\Content\Microsoft.ManifestTool.dll generate -b $(ArtifactsDir)Vsix\Unpacked\%(VsixFile.Filename) -m $(ArtifactsDir)sbom\%(VsixFile.Filename) -pn VsInsertion -V Verbose"/>
<Message Text="Completed generating SBOM manifest for %(VsixFile.Filename)." Importance="high"/>
</Target>
<!---
This target is invoked in a separate phase after all input VSIX files are signed.
This is important since the manifest contain hashes of the VSIX files.
-->
<Target Name="GenerateVisualStudioInsertionManifests"
BeforeTargets="AfterPack"
Outputs="%(_StubDirs.Identity)"
Condition="'@(_StubDirs)' != ''"
DependsOnTargets="GenerateSbomForVSInsertion">
Condition="'@(_StubDirs)' != ''">
<PropertyGroup>
<_ComponentDir>%(_StubDirs.Identity)</_ComponentDir>
<_ComponentName>$(_ComponentDir.TrimEnd('\'))</_ComponentName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,21 @@

<Import Project="$(SwixBuildPath)build\Microsoft.VisualStudioEng.MicroBuild.Plugins.SwixBuild.targets" />

<Target Name="_BuildManifest" DependsOnTargets="_SetManifestBuildVersion;GenerateSetupManifest" />
<Target Name="_BuildManifest" DependsOnTargets="_GetVsixFileVersions;GenerateSbomForVSInsertion;GenerateVSManifest;GenerateSetupManifest" />

<!--
Each stub file contains VSIX version of the respective VSIX file.
We require that all VSIXes included in a single VS insertion component have the same version.
This version will be set to ManifestBuildVersion.
-->
<Target Name="_SetManifestBuildVersion">
<Target Name="_GetVsixFileVersions">

<ReadLinesFromFile File="%(_PackageStubFiles.Identity)">
<Output TaskParameter="Lines" ItemName="_StubLine"/>
</ReadLinesFromFile>

<ItemGroup>
<_StubLineSplit Include="@(_StubLine)"
Name="$([MSBuild]::ValueOrDefault('%(_StubLine.Identity)', '').Split('/')[0])"
Version="$([MSBuild]::ValueOrDefault('%(_StubLine.Identity)', '').Split('/')[1])" />
</ItemGroup>
<_VsixFileInfo Include="@(_StubLine)"
Name="$([MSBuild]::ValueOrDefault('%(_StubLine.Identity)', '').Split('/')[0])"
Version="$([MSBuild]::ValueOrDefault('%(_StubLine.Identity)', '').Split('/')[1])" />
</ItemGroup>

<ItemGroup>
<_VsixVersion Include="%(_StubLineSplit.Version)" Name="%(_StubLineSplit.Name)" />
<_VsixVersion Include="%(_VsixFileInfo.Version)" Name="%(_VsixFileInfo.Name)" />
</ItemGroup>

<RemoveDuplicates Inputs="@(_VsixVersion)">
Expand All @@ -77,7 +71,31 @@

<Error Text="Visual Studio component '$(ComponentName)' contains multiple VSIX files with different versions: @(_VsixVersionNoDuplicates->'%(Name) (version %(Identity))', ', ')"
Condition="@(_VsixVersionNoDuplicates->Count()) != 1"/>
</Target>

<Target Name="GenerateSbomForVSInsertion"
Inputs="@(_VsixFileInfo->'$(ArtifactsDir)VSSetup\$(Configuration)\Insertion\%(Name)')"
epananth marked this conversation as resolved.
Show resolved Hide resolved
Outputs="@(_VsixFileInfo->'$(ArtifactsDir)VSSetup\$(Configuration)\Insertion\$(ComponentName)\%(Name)')"
epananth marked this conversation as resolved.
Show resolved Hide resolved
DependsOnTargets="_GetVsixFileVersions"
Condition="'$(GenerateSbom)' != 'false'">
epananth marked this conversation as resolved.
Show resolved Hide resolved
<Message Text="Generating SBOM manifest" Importance="high"/>
<MakeDir Directories="$(ComponentIntermediateOutputPath)$(ComponentName)\Sbom;$(ComponentIntermediateOutputPath)$(ComponentName)\unpacked"/>
epananth marked this conversation as resolved.
Show resolved Hide resolved
<Unzip
SourceFiles="@(_VsixFileInfo->'$(ArtifactsDir)VSSetup\$(Configuration)\Insertion\%(Name)')"
DestinationFolder="$(ComponentIntermediateOutputPath)$(ComponentName)\unpacked"
OverwriteReadOnlyFiles="true"/>

<Exec Command = "$(DotNetTool) $(NUGET_PACKAGES)microsoft.manifesttool.crossplatform\$(MicrosoftManifestToolCrossPlatformVersion)\Content\Microsoft.ManifestTool.dll generate -b $(ComponentIntermediateOutputPath)$(ComponentName)\unpacked -m $(ComponentIntermediateOutputPath)$(ComponentName)\Sbom -pn VsInsertion -V Verbose"/>
<Message Text="Completed generating SBOM manifest for %(VsixFile.Filename)." Importance="high"/>
</Target>

<!--
Each stub file contains VSIX version of the respective VSIX file.
We require that all VSIXes included in a single VS insertion component have the same version.
This version will be set to ManifestBuildVersion.
-->

<Target Name= "GenerateVSManifest" DependsOnTargets="GenerateSbomForVSInsertion">
<PropertyGroup>
<ManifestBuildVersion>@(_VsixVersionNoDuplicates)</ManifestBuildVersion>
<ManifestVsixName>@(_VsixVersionNoDuplicates->'%(Name)')</ManifestVsixName>
Expand Down