Permalink
Browse files

Workaround Reg-Free COM issues by using the underlying location on Ap…

…p Services
  • Loading branch information...
onovotny committed Jan 10, 2018
1 parent 3f4a13c commit 94f0c01db071a1d1da6110e23e8d3fcbb3d645fb
@@ -10,10 +10,10 @@
</PropertyGroup>
<ItemGroup>
<!--<SdkFile Include="$(WinSdkBinDir)appxpackaging.dll" />
<SdkFile Include="$(WinSdkBinDir)appxpackaging.dll" />
<SdkFile Include="$(WinSdkBinDir)opcservices.dll" />
<SdkFile Include="$(WinSdkBinDir)Microsoft.Windows.Build.Appx.AppxPackaging.dll.manifest" />
<SdkFile Include="$(WinSdkBinDir)Microsoft.Windows.Build.Appx.OpcServices.dll.manifest" />-->
<SdkFile Include="$(WinSdkBinDir)Microsoft.Windows.Build.Appx.OpcServices.dll.manifest" />
<SdkFile Include="$(WinSdkBinDir)makeappx.exe" />
<SdkFile Include="$(WinSdkBinDir)makepri.exe" />
@@ -43,10 +43,6 @@
<Target Name="PrebuildScript" BeforeTargets="CoreBuild">
<Copy SourceFiles="@(SdkFile)" DestinationFolder="tools\SDK" SkipUnchangedFiles="true" />
<PropertyGroup>
<MtCmd>"$(WinSdkBinDir)mt.exe" -nologo -manifest blank.manifest -outputresource:tools\SDK\makeappx.exe;#1</MtCmd>
</PropertyGroup>
<Exec Command="$(MtCmd)" WorkingDirectory="$(MSBuildThisFileDirectory)" />
</Target>
<ItemGroup>
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace SignService.SigningTools
{
@@ -22,11 +23,11 @@ public class SigningToolAggregate : ISigningToolAggregate
public SigningToolAggregate(IEnumerable<ICodeSignService> services,
IHostingEnvironment hostingEnvironment,
IOptionsSnapshot<WindowsSdkFiles> windowSdkFiles,
ILogger<SigningToolAggregate> logger)
{
this.logger = logger;
makeappxPath = Path.Combine(hostingEnvironment.ContentRootPath, "tools\\SDK\\makeappx.exe");
makeappxPath = windowSdkFiles.Value.MakeAppxPath;
// pe files
defaultCodeSignService = services.Single(c => c.IsDefault);
@@ -78,9 +79,9 @@ public async Task Submit(HashMode hashMode, string name, string description, str
// expand the archives and sign recursively first
var bundles = (from file in files
let ext = Path.GetExtension(file).ToLowerInvariant()
where ext == ".appxbundle"
select file).ToList();
let ext = Path.GetExtension(file).ToLowerInvariant()
where ext == ".appxbundle" || ext == ".eappxbundle"
select file).ToList();
var tempBundles = new List<AppxBundleFile>();
try
@@ -65,6 +65,7 @@ public void ConfigureServices(IServiceCollection services)
services.Configure<ResourceIds>(Configuration.GetSection("Resources"));
services.Configure<AdminConfig>(Configuration.GetSection("Admin"));
services.Configure<WindowsSdkFiles>(ConfigureWindowsSdkFiles);
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<ITelemetryLogger, TelemetryLogger>();
@@ -150,6 +151,26 @@ static void AddEnvironmentPaths(IEnumerable<string> paths)
Environment.SetEnvironmentVariable("PATH", newPath);
}
void ConfigureWindowsSdkFiles(WindowsSdkFiles options)
{
var contentPath = environment.ContentRootPath;
// If we're running on Azure App Services, we have to invoke from the underlying
// location due to CSRSS/registration-free COM manifest issues
// running on azure
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("REGION_NAME")))
{
var home = Environment.GetEnvironmentVariable("HOME_EXPANDED");
if (!string.IsNullOrWhiteSpace(home))
{
contentPath = $@"{home}\site\wwwroot";
}
}
options.MakeAppxPath = Path.Combine(contentPath, "tools\\SDK\\makeappx.exe");
}
private class SnapshotCollectorTelemetryProcessorFactory : ITelemetryProcessorFactory
{
private readonly IServiceProvider _serviceProvider;
@@ -2,6 +2,7 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SignService.Services;
namespace SignService.Utils
@@ -18,11 +19,11 @@ public class AppxFileFactory : IAppxFileFactory
string publisher;
readonly string makeappxPath;
public AppxFileFactory(ILogger<AppxFileFactory> logger, IHostingEnvironment hostingEnvironment, IKeyVaultService keyVaultService)
public AppxFileFactory(ILogger<AppxFileFactory> logger, IOptionsSnapshot<WindowsSdkFiles> windowSdkFiles, IKeyVaultService keyVaultService)
{
this.logger = logger;
this.keyVaultService = keyVaultService;
makeappxPath = Path.Combine(hostingEnvironment.ContentRootPath, "tools\\SDK\\makeappx.exe");
makeappxPath = windowSdkFiles.Value.MakeAppxPath;
}
public AppxFile Create(string inputFileName)
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SignService
{
public class WindowsSdkFiles
{
public string MakeAppxPath { get; set; }
}
}

0 comments on commit 94f0c01

Please sign in to comment.