1+ param (
2+ [ValidateSet (" Debug" , " Release" )]
3+ [Parameter (Position = 0 )]
4+ [string ] $Configuration = " Release"
5+ )
6+
17$WorkingDir = split-path - parent $MyInvocation.MyCommand.Definition
28
39function Write-Diagnostic
@@ -24,26 +30,43 @@ function GenerateRefAssemblySource
2430 $client = New-Object System.Net.WebClient;
2531 # https://www.myget.org/F/cefsharp/api/v2/package/Microsoft.DotNet.GenAPI/6.0.0-beta.20610.4
2632 $downloadUrl = ' https://www.myget.org/F/cefsharp/api/v2/package/Microsoft.DotNet.GenAPI/' + $genapiVersion
33+ Write-Diagnostic " Attempting to download $downloadUrl "
2734 $client.DownloadFile ($downloadUrl , $genapiNupkg );
2835 # Expand-Archive won't extract a nupkg file, simply rename to zip
2936 Rename-Item - Path $genapiNupkg - NewName $genapiZip
3037
3138 Expand-Archive - LiteralPath $genapiZip - DestinationPath (Join-Path $toolsFolder microsoft.dotnet.genapi.$genapiVersion )
3239 }
3340
34- # .\Microsoft.DotNet.GenAPI.exe C:\projects\CefSharp\CefSharp.Core.Runtime\bin\Win32\Debug\CefSharp.Core.Runtime.dll --lang-version 7.1 --lib-path C:\projects\CefSharp\CefSharp\bin\Debug --out CefSharp.Core.Runtime.cs
35-
36- $inputDll = Join-Path $WorkingDir \CefSharp.Core.Runtime\bin\Win32\Release\CefSharp.Core.Runtime.dll
37- $outputFile = Join-Path $WorkingDir \CefSharp.Core.Runtime.RefAssembly\CefSharp.Core.Runtime.cs
38- $cefSharpDllPath = Join-Path $WorkingDir \CefSharp\bin\Release\
39- $mscorlibDllPath = (Get-Item ([System.String ].Assembly.Location)).Directory.ToString()
40- $libPath = $cefSharpDllPath + ' ;' + $mscorlibDllPath
41+ $inputDll = Join-Path $WorkingDir \CefSharp.Core.Runtime\bin\Win32\$Configuration \CefSharp.Core.Runtime.dll
42+ # This is a little problematic in developmenet as Win32 version might not nessicarily be the current target build
43+ # as yet I've not found a way to get the solution
44+ if (-not (Test-Path $inputDll ))
45+ {
46+ $inputDll = Join-Path $WorkingDir \CefSharp.Core.Runtime\bin\x64\$Configuration \CefSharp.Core.Runtime.dll
47+ }
48+
49+ if ((Test-Path $inputDll ))
50+ {
51+ $outputFile = Join-Path $WorkingDir \CefSharp.Core.Runtime.RefAssembly\CefSharp.Core.Runtime.cs
52+ $cefSharpDllPath = Join-Path $WorkingDir \CefSharp\bin\$Configuration \
53+ $mscorlibDllPath = (Get-Item ([System.String ].Assembly.Location)).Directory.ToString()
54+ $libPath = $cefSharpDllPath + ' ;' + $mscorlibDllPath
4155
42- . $genapi $inputDll -- lang- version 7.1 -- lib- path $libPath -- out $outputFile
43- Write-Diagnostic " Generated Ref Assembly Source $outputFile "
56+ . $genapi $inputDll -- lang- version 7.1 -- lib- path $libPath -- out $outputFile
4457
45- # Generates slightly incorrect C#, so just manually fix it.
46- ((Get-Content - path $outputFile - Raw) -replace ' public sealed override void Dispose' , ' public void Dispose' ) | Set-Content - Path $outputFile
58+ # Generates slightly incorrect C#, so just manually fix it.
59+ $outputFileText = ((Get-Content - path $outputFile - Raw) -replace ' public sealed override void Dispose' , ' public void Dispose' )
60+ $outputFileText = $outputFileText.Trim ()
61+
62+ # Set-Content puts an empty line at the end, so use WriteAllText instead
63+ [System.IO.File ]::WriteAllText($outputFile , $outputFileText )
64+ Write-Diagnostic " Generated Ref Assembly Source $outputFile "
65+ }
66+ else
67+ {
68+ Write-Diagnostic " Unable to Generate Ref Assembly Source, file not found $inputDll "
69+ }
4770}
4871
4972GenerateRefAssemblySource
0 commit comments