[gh-142, gh-111] Potential build fixes. Updated Insights to record the app name.
This commit is contained in:
Родитель
94530a7833
Коммит
170d77bf75
|
@ -28,7 +28,7 @@ namespace AssemblyResolver.Steps {
|
||||||
rewritten = true;
|
rewritten = true;
|
||||||
}
|
}
|
||||||
if (rewritten) {
|
if (rewritten) {
|
||||||
WriteAssembly(assembly, targetPath);
|
WriteAssembly(assembly, targetPath, mainAssemblies);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Copy.File(assembly.Path, targetPath);
|
Copy.File(assembly.Path, targetPath);
|
||||||
|
@ -37,7 +37,7 @@ namespace AssemblyResolver.Steps {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteAssembly(AssemblyDetails assembly, string targetPath) {
|
private static void WriteAssembly(AssemblyDetails assembly, string targetPath, IImmutableDictionary<AssemblyShortName, AssemblyDetails> mainAssemblies) {
|
||||||
var assemblyName = assembly.Definition.Name;
|
var assemblyName = assembly.Definition.Name;
|
||||||
assemblyName.PublicKey = new byte[0];
|
assemblyName.PublicKey = new byte[0];
|
||||||
assemblyName.PublicKeyToken = new byte[0];
|
assemblyName.PublicKeyToken = new byte[0];
|
||||||
|
@ -49,6 +49,12 @@ namespace AssemblyResolver.Steps {
|
||||||
resolver.RemoveSearchDirectory(defaultPath);
|
resolver.RemoveSearchDirectory(defaultPath);
|
||||||
}
|
}
|
||||||
resolver.AddSearchDirectory(targetDirectoryPath);
|
resolver.AddSearchDirectory(targetDirectoryPath);
|
||||||
|
resolver.ResolveFailure += (sender, reference) => {
|
||||||
|
var mainAssembly = mainAssemblies.GetValueOrDefault(reference.Name);
|
||||||
|
if (mainAssembly == null)
|
||||||
|
return null;
|
||||||
|
return mainAssembly.Definition;
|
||||||
|
};
|
||||||
assembly.Definition.Write(targetPath);
|
assembly.Definition.Write(targetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ Set-StrictMode -Version 2.0
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
$ProgressPreference = "SilentlyContinue" # https://www.amido.com/powershell-win32-error-handle-invalid-0x6/
|
$ProgressPreference = "SilentlyContinue" # https://www.amido.com/powershell-win32-error-handle-invalid-0x6/
|
||||||
|
|
||||||
# Note: Write-Host, Write-Error and Write-Warning do not function properly in Azure
|
|
||||||
."$PSScriptRoot\Setup-Build.ps1"
|
."$PSScriptRoot\Setup-Build.ps1"
|
||||||
|
|
||||||
$branchFsName = $branchName -replace '[/\\:_]', '-'
|
$branchFsName = $branchName -replace '[/\\:_]', '-'
|
||||||
|
@ -37,13 +36,6 @@ if (Test-Path "$sourceRoot\Binaries") {
|
||||||
Remove-Item "$sourceRoot\Binaries" -Recurse -Force
|
Remove-Item "$sourceRoot\Binaries" -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Output "Building '$branchName'..."
|
|
||||||
|
|
||||||
$buildLogPath = "$(Resolve-Path "$sourceRoot\..")\$([IO.Path]::GetFileName($sourceRoot))-$branchFsName.build.log"
|
|
||||||
if (Test-Path $buildLogPath) {
|
|
||||||
Remove-Item $buildLogPath
|
|
||||||
}
|
|
||||||
|
|
||||||
function Build-Project(
|
function Build-Project(
|
||||||
[Parameter(Mandatory=$true)][string[]] $candidateProjectPaths,
|
[Parameter(Mandatory=$true)][string[]] $candidateProjectPaths,
|
||||||
[string] $msbuildArgs
|
[string] $msbuildArgs
|
||||||
|
@ -52,33 +44,42 @@ function Build-Project(
|
||||||
if (!$projectPath) {
|
if (!$projectPath) {
|
||||||
throw New-Object BranchBuildException("Project not found: none of @($candidateProjectPaths) matched.", $buildLogPath)
|
throw New-Object BranchBuildException("Project not found: none of @($candidateProjectPaths) matched.", $buildLogPath)
|
||||||
}
|
}
|
||||||
" $projectPath $msbuildArgs" | Out-Default
|
" msbuild $projectPath $msbuildArgs" | Out-Default
|
||||||
|
&$MSBuild $projectPath /m /p:Configuration=Release /p:DelaySign=false /p:SignAssembly=false /p:NeedsFakeSign=false /p:SolutionDir="$sourceRoot\Src" >> "$buildLogPath"
|
||||||
$projectPath = "$sourceRoot\$projectPath"
|
|
||||||
" dotnet restore" | Out-Default
|
|
||||||
dotnet restore "$projectPath" >> "$buildLogPath"
|
|
||||||
" dotnet build" | Out-Default
|
|
||||||
Invoke-Expression ("dotnet build `"$projectPath`" $msbuildArgs >> `"$buildLogPath`"")
|
|
||||||
if ($LastExitCode -ne 0) {
|
if ($LastExitCode -ne 0) {
|
||||||
throw New-Object BranchBuildException("Build failed, see $buildLogPath", $buildLogPath)
|
throw New-Object BranchBuildException("Build failed, see $buildLogPath", $buildLogPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$standardArgs = "/p:RestorePackages=false /p:Configuration=Debug /p:DelaySign=false /p:SignAssembly=false /p:NeedsFakeSign=false /p:SolutionDir=`"$sourceRoot\Src`""
|
Write-Output "Building '$branchName'..."
|
||||||
Build-Project "Src\Compilers\Core\Portable\CodeAnalysis.csproj" $standardArgs
|
|
||||||
Build-Project "Src\Compilers\CSharp\Portable\CSharpCodeAnalysis.csproj" $standardArgs
|
|
||||||
Build-Project "src\Features\CSharp\Portable\CSharpFeatures.csproj" $standardArgs
|
|
||||||
Build-Project "Src\Tools\Source\CompilerGeneratorTools\Source\VisualBasicSyntaxGenerator\VisualBasicSyntaxGenerator.vbproj" $standardArgs
|
|
||||||
Build-Project "Src\Compilers\VisualBasic\Portable\BasicCodeAnalysis.vbproj" "$standardArgs /p:IldasmPath=`"$(Resolve-Path "$sourceRoot\..\..\!tools\ildasm.exe")`""
|
|
||||||
Build-Project "src\Features\VisualBasic\Portable\BasicFeatures.vbproj" $standardArgs
|
|
||||||
|
|
||||||
if (Test-Path "$sourceRoot\NuGet.config") {
|
$buildLogPath = "$(Resolve-Path "$sourceRoot\..")\$([IO.Path]::GetFileName($sourceRoot))-$branchFsName.build.log"
|
||||||
Remove-Item "$sourceRoot\NuGet.config"
|
if (Test-Path $buildLogPath) {
|
||||||
|
Remove-Item $buildLogPath
|
||||||
}
|
}
|
||||||
|
|
||||||
robocopy "$sourceRoot\Binaries\Debug" "$artifactsRoot\Binaries\Debug" `
|
Push-Location $sourceRoot
|
||||||
/xd "$sourceRoot\Binaries\Debug\Exes" `
|
try {
|
||||||
/xd "$sourceRoot\Binaries\Debug\CompilerGeneratorTools" `
|
if (!(Test-Path '.\Restore.cmd')) {
|
||||||
|
throw New-Object BranchBuildException("Build failed: Restore.cmd not found.", $buildLogPath)
|
||||||
|
}
|
||||||
|
Write-Output " .\Restore.cmd"
|
||||||
|
.\Restore.cmd >> "$buildLogPath"
|
||||||
|
|
||||||
|
Build-Project "Src\Compilers\Core\Portable\CodeAnalysis.csproj"
|
||||||
|
Build-Project "Src\Compilers\CSharp\Portable\CSharpCodeAnalysis.csproj"
|
||||||
|
Build-Project "src\Features\CSharp\Portable\CSharpFeatures.csproj"
|
||||||
|
Build-Project "Src\Tools\Source\CompilerGeneratorTools\Source\VisualBasicSyntaxGenerator\VisualBasicSyntaxGenerator.vbproj"
|
||||||
|
Build-Project "Src\Compilers\VisualBasic\Portable\BasicCodeAnalysis.vbproj"
|
||||||
|
Build-Project "src\Features\VisualBasic\Portable\BasicFeatures.vbproj"
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
|
||||||
|
robocopy "$sourceRoot\Binaries\Release" "$artifactsRoot\Binaries\Release" `
|
||||||
|
/xd "$sourceRoot\Binaries\Release\Exes" `
|
||||||
|
/xd "$sourceRoot\Binaries\Release\CompilerGeneratorTools" `
|
||||||
/xd "runtimes" `
|
/xd "runtimes" `
|
||||||
/mir /np
|
/mir /np
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ try {
|
||||||
Write-Output "Updating $branchesFileName..."
|
Write-Output "Updating $branchesFileName..."
|
||||||
Set-Content "$sitesRoot\$branchesFileName" $(ConvertTo-Json $branchesJson -Depth 100)
|
Set-Content "$sitesRoot\$branchesFileName" $(ConvertTo-Json $branchesJson -Depth 100)
|
||||||
|
|
||||||
$brachesJsLocalRoot = "$sourceRoot\Web\wwwroot"
|
$brachesJsLocalRoot = "$sourceRoot\WebApp\wwwroot"
|
||||||
if (!(Test-Path $brachesJsLocalRoot)) {
|
if (!(Test-Path $brachesJsLocalRoot)) {
|
||||||
New-Item -ItemType Directory -Path $brachesJsLocalRoot | Out-Null
|
New-Item -ItemType Directory -Path $brachesJsLocalRoot | Out-Null
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,13 @@ if (!$webApp) {
|
||||||
-ResourceGroupName $resourceGroupName `
|
-ResourceGroupName $resourceGroupName `
|
||||||
-Name $webAppName `
|
-Name $webAppName `
|
||||||
-WebSocketsEnabled $true | Out-Null
|
-WebSocketsEnabled $true | Out-Null
|
||||||
|
Set-AzureRmWebApp `
|
||||||
|
-ResourceGroupName $resourceGroupName `
|
||||||
|
-Name $webAppName `
|
||||||
|
-AppSettings @{
|
||||||
|
SHARPLAB_WEBAPP_NAME = $webAppName
|
||||||
|
SHARPLAB_TELEMETRY_KEY = $env:SHARPLAB_TELEMETRY_KEY
|
||||||
|
} | Out-Null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Output " Found web app $($webApp.Name)"
|
Write-Output " Found web app $($webApp.Name)"
|
||||||
|
|
|
@ -10,9 +10,11 @@ using SharpLab.Server.Monitoring;
|
||||||
namespace SharpLab.Server.Azure {
|
namespace SharpLab.Server.Azure {
|
||||||
public class ApplicationInsightsMonitor : IMonitor {
|
public class ApplicationInsightsMonitor : IMonitor {
|
||||||
private readonly TelemetryClient _client;
|
private readonly TelemetryClient _client;
|
||||||
|
private readonly string _webAppName;
|
||||||
|
|
||||||
public ApplicationInsightsMonitor(TelemetryClient client) {
|
public ApplicationInsightsMonitor(TelemetryClient client, string webAppName) {
|
||||||
_client = client;
|
_client = client;
|
||||||
|
_webAppName = webAppName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Event(string name, IWorkSession session, IDictionary<string, string> extras = null) {
|
public void Event(string name, IWorkSession session, IDictionary<string, string> extras = null) {
|
||||||
|
@ -31,10 +33,11 @@ namespace SharpLab.Server.Azure {
|
||||||
_client.TrackException(telemetry);
|
_client.TrackException(telemetry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddDefaultDetails<TTelemetry>(TTelemetry telemetry, IWorkSession session, IDictionary<string, string> extras)
|
private void AddDefaultDetails<TTelemetry>(TTelemetry telemetry, IWorkSession session, IDictionary<string, string> extras)
|
||||||
where TTelemetry: ITelemetry, ISupportProperties
|
where TTelemetry: ITelemetry, ISupportProperties
|
||||||
{
|
{
|
||||||
telemetry.Context.Session.Id = session?.GetSessionId();
|
telemetry.Context.Session.Id = session?.GetSessionId();
|
||||||
|
telemetry.Context.Properties.Add("Web App", _webAppName);
|
||||||
if (extras == null)
|
if (extras == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,10 @@ namespace SharpLab.Server.Azure {
|
||||||
builder.RegisterInstance(new TelemetryClient(configuration))
|
builder.RegisterInstance(new TelemetryClient(configuration))
|
||||||
.AsSelf();
|
.AsSelf();
|
||||||
|
|
||||||
|
var webAppName = Environment.GetEnvironmentVariable("SHARPLAB_WEBAPP_NAME");
|
||||||
builder.RegisterType<ApplicationInsightsMonitor>()
|
builder.RegisterType<ApplicationInsightsMonitor>()
|
||||||
.As<IMonitor>()
|
.As<IMonitor>()
|
||||||
|
.WithParameter("webAppName", webAppName)
|
||||||
.SingleInstance();
|
.SingleInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче