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

Fix installation for library and template packs #7651

Merged
merged 4 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -17,6 +17,15 @@ public class GenerateManifestMsi : GenerateTaskBase
{
private Version _sdkFeaureBandVersion;

pjcollins marked this conversation as resolved.
Show resolved Hide resolved
/// <summary>
/// Gets or sets whether a corresponding SWIX project should be generated for the MSI.
/// </summary>
public bool GenerateSwixAuthoring
{
get;
set;
} = true;

/// <summary>
/// The path where the generated MSIs will be placed.
/// </summary>
Expand Down Expand Up @@ -252,6 +261,19 @@ public override bool Execute()
msi.SetMetadata(Metadata.JsonProperties, msiJsonPath);
msi.SetMetadata(Metadata.WixObj, candleIntermediateOutputPath);

if (GenerateSwixAuthoring && IsSupportedByVisualStudio(platform))
{
string swixPackageId = $"{nupkg.Id}";

string swixProject = GenerateSwixPackageAuthoring(light.OutputFile,
swixPackageId, platform);

if (!string.IsNullOrWhiteSpace(swixProject))
{
msi.SetMetadata(Metadata.SwixProject, swixProject);
}
}

// Generate a .csproj to build a NuGet payload package to carry the MSI and JSON manifest
msi.SetMetadata(Metadata.PackageProject, GeneratePackageProject(msi.ItemSpec, msiJsonPath, platform, nupkg));

Expand Down Expand Up @@ -358,5 +380,24 @@ private void WriteItem(XmlWriter writer, string itemName, string include, string
writer.WriteAttributeString("PackagePath", packagePath);
writer.WriteEndElement();
}

private string GenerateSwixPackageAuthoring(string msiPath, string packageId, string platform)
{
GenerateVisualStudioMsiPackageProject swixTask = new()
{
Chip = platform,
IntermediateBaseOutputPath = this.IntermediateBaseOutputPath,
PackageName = packageId,
MsiPath = msiPath,
BuildEngine = this.BuildEngine,
};

if (!swixTask.Execute())
{
Log.LogError($"Failed to generate SWIX authoring for '{msiPath}'");
}

return swixTask.SwixProject;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
string packageContentsDirectory = Path.Combine(PackageDirectory, $"{nupkg.Identity}");
IEnumerable<string> exclusions = GetExlusionPatterns();
string installDir = GetInstallDir(kind);
string packKind = kind.ToString().ToLowerInvariant();

if ((kind != WorkloadPackKind.Library) && (kind != WorkloadPackKind.Template))
{
Expand Down Expand Up @@ -174,10 +175,14 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
string packageContentWxs = Path.Combine(msiSourcePath, "PackageContent.wxs");
sourceFiles.Add(packageContentWxs);

string directoryReference = (kind == WorkloadPackKind.Library) || (kind == WorkloadPackKind.Template)
? "InstallDir"
: PackageContentDirectoryReference;

HarvestToolTask heat = new(BuildEngine, WixToolsetPath)
{
ComponentGroupName = PackageContentComponentGroupName,
DirectoryReference = PackageContentDirectoryReference,
DirectoryReference = directoryReference,
OutputFile = packageContentWxs,
Platform = platform,
SourceDirectory = packageContentsDirectory
Expand Down Expand Up @@ -216,6 +221,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
candle.PreprocessorDefinitions.Add($@"SourceDir={packageContentsDirectory}");
candle.PreprocessorDefinitions.Add($@"Manufacturer={manufacturer}");
candle.PreprocessorDefinitions.Add($@"EulaRtf={EulaRtfPath}");
candle.PreprocessorDefinitions.Add($@"PackKind={packKind}");

// Compiler extension to process dependency provider authoring for package reference counting.
candle.Extensions.Add("WixDependencyExtension");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<Directory Id="$(var.ProgramFilesFolder)">
<Directory Id="DOTNETHOME" Name="dotnet">
<Directory Id="InstallDir" Name="$(var.InstallDir)">
<?if $(var.PackKind) != "library" and $(var.PackKind) != "template"?>
<Directory Id="PackageDir" Name="$(var.PackageId)">
<Directory Id="VersionDir" Name="$(var.PackageVersion)" />
</Directory>
<?endif?>
</Directory>
</Directory>
</Directory>
Expand Down