[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;
|
||||
}
|
||||
if (rewritten) {
|
||||
WriteAssembly(assembly, targetPath);
|
||||
WriteAssembly(assembly, targetPath, mainAssemblies);
|
||||
}
|
||||
else {
|
||||
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;
|
||||
assemblyName.PublicKey = new byte[0];
|
||||
assemblyName.PublicKeyToken = new byte[0];
|
||||
|
@ -49,6 +49,12 @@ namespace AssemblyResolver.Steps {
|
|||
resolver.RemoveSearchDirectory(defaultPath);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ Set-StrictMode -Version 2.0
|
|||
$ErrorActionPreference = 'Stop'
|
||||
$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"
|
||||
|
||||
$branchFsName = $branchName -replace '[/\\:_]', '-'
|
||||
|
@ -37,13 +36,6 @@ if (Test-Path "$sourceRoot\Binaries") {
|
|||
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(
|
||||
[Parameter(Mandatory=$true)][string[]] $candidateProjectPaths,
|
||||
[string] $msbuildArgs
|
||||
|
@ -52,33 +44,42 @@ function Build-Project(
|
|||
if (!$projectPath) {
|
||||
throw New-Object BranchBuildException("Project not found: none of @($candidateProjectPaths) matched.", $buildLogPath)
|
||||
}
|
||||
" $projectPath $msbuildArgs" | Out-Default
|
||||
|
||||
$projectPath = "$sourceRoot\$projectPath"
|
||||
" dotnet restore" | Out-Default
|
||||
dotnet restore "$projectPath" >> "$buildLogPath"
|
||||
" dotnet build" | Out-Default
|
||||
Invoke-Expression ("dotnet build `"$projectPath`" $msbuildArgs >> `"$buildLogPath`"")
|
||||
" 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"
|
||||
if ($LastExitCode -ne 0) {
|
||||
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`""
|
||||
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
|
||||
Write-Output "Building '$branchName'..."
|
||||
|
||||
if (Test-Path "$sourceRoot\NuGet.config") {
|
||||
Remove-Item "$sourceRoot\NuGet.config"
|
||||
$buildLogPath = "$(Resolve-Path "$sourceRoot\..")\$([IO.Path]::GetFileName($sourceRoot))-$branchFsName.build.log"
|
||||
if (Test-Path $buildLogPath) {
|
||||
Remove-Item $buildLogPath
|
||||
}
|
||||
|
||||
robocopy "$sourceRoot\Binaries\Debug" "$artifactsRoot\Binaries\Debug" `
|
||||
/xd "$sourceRoot\Binaries\Debug\Exes" `
|
||||
/xd "$sourceRoot\Binaries\Debug\CompilerGeneratorTools" `
|
||||
Push-Location $sourceRoot
|
||||
try {
|
||||
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" `
|
||||
/mir /np
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ try {
|
|||
Write-Output "Updating $branchesFileName..."
|
||||
Set-Content "$sitesRoot\$branchesFileName" $(ConvertTo-Json $branchesJson -Depth 100)
|
||||
|
||||
$brachesJsLocalRoot = "$sourceRoot\Web\wwwroot"
|
||||
$brachesJsLocalRoot = "$sourceRoot\WebApp\wwwroot"
|
||||
if (!(Test-Path $brachesJsLocalRoot)) {
|
||||
New-Item -ItemType Directory -Path $brachesJsLocalRoot | Out-Null
|
||||
}
|
||||
|
|
|
@ -37,6 +37,13 @@ if (!$webApp) {
|
|||
-ResourceGroupName $resourceGroupName `
|
||||
-Name $webAppName `
|
||||
-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 {
|
||||
Write-Output " Found web app $($webApp.Name)"
|
||||
|
|
|
@ -10,9 +10,11 @@ using SharpLab.Server.Monitoring;
|
|||
namespace SharpLab.Server.Azure {
|
||||
public class ApplicationInsightsMonitor : IMonitor {
|
||||
private readonly TelemetryClient _client;
|
||||
private readonly string _webAppName;
|
||||
|
||||
public ApplicationInsightsMonitor(TelemetryClient client) {
|
||||
public ApplicationInsightsMonitor(TelemetryClient client, string webAppName) {
|
||||
_client = client;
|
||||
_webAppName = webAppName;
|
||||
}
|
||||
|
||||
public void Event(string name, IWorkSession session, IDictionary<string, string> extras = null) {
|
||||
|
@ -31,10 +33,11 @@ namespace SharpLab.Server.Azure {
|
|||
_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
|
||||
{
|
||||
telemetry.Context.Session.Id = session?.GetSessionId();
|
||||
telemetry.Context.Properties.Add("Web App", _webAppName);
|
||||
if (extras == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -17,8 +17,10 @@ namespace SharpLab.Server.Azure {
|
|||
builder.RegisterInstance(new TelemetryClient(configuration))
|
||||
.AsSelf();
|
||||
|
||||
var webAppName = Environment.GetEnvironmentVariable("SHARPLAB_WEBAPP_NAME");
|
||||
builder.RegisterType<ApplicationInsightsMonitor>()
|
||||
.As<IMonitor>()
|
||||
.WithParameter("webAppName", webAppName)
|
||||
.SingleInstance();
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче