diff --git a/.nuget/packages.config b/.nuget/packages.config deleted file mode 100644 index a05271e70..000000000 --- a/.nuget/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/CefSharp.Core/BrowserSettings.h b/CefSharp.Core/BrowserSettings.h index dcd6be4e9..bd47ec32a 100644 --- a/CefSharp.Core/BrowserSettings.h +++ b/CefSharp.Core/BrowserSettings.h @@ -272,10 +272,5 @@ namespace CefSharp void set(Nullable^ value) { _browserSettings->webgl = CefStateFromDisabledSetting(value); } } - property Nullable^ AcceleratedCompositingDisabled - { - Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->accelerated_compositing); } - void set(Nullable^ value) { _browserSettings->accelerated_compositing = CefStateFromDisabledSetting(value); } - } }; } \ No newline at end of file diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h index 6ea7131dc..f90fe5a8e 100644 --- a/CefSharp.Core/Cef.h +++ b/CefSharp.Core/Cef.h @@ -331,7 +331,7 @@ namespace CefSharp auto wrapper = new CompletionHandler(handler); - return manager->FlushStore(static_cast>(wrapper)); + return manager->FlushStore(static_cast>(wrapper)); } /// Shuts down CefSharp and the underlying CEF infrastructure. This method is safe to call multiple times; it will only diff --git a/CefSharp.Core/CefSettings.h b/CefSharp.Core/CefSettings.h index 0d5dd0573..935bb4843 100644 --- a/CefSharp.Core/CefSettings.h +++ b/CefSharp.Core/CefSettings.h @@ -34,8 +34,6 @@ namespace CefSharp return LOGSEVERITY_WARNING; case CefSharp::LogSeverity::Error: return LOGSEVERITY_ERROR; - case CefSharp::LogSeverity::ErrorReport: - return LOGSEVERITY_ERROR_REPORT; case CefSharp::LogSeverity::Disable: default: return LOGSEVERITY_DISABLE; @@ -54,8 +52,6 @@ namespace CefSharp return CefSharp::LogSeverity::Warning; case LOGSEVERITY_ERROR: return CefSharp::LogSeverity::Error; - case LOGSEVERITY_ERROR_REPORT: - return CefSharp::LogSeverity::ErrorReport; case LOGSEVERITY_DISABLE: default: return CefSharp::LogSeverity::Disable; diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index a29710e96..d557d10e7 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -1,6 +1,6 @@  - + Debug @@ -66,6 +66,7 @@ <_ProjectFileVersion>11.0.51106.1 + 9aa99f24 bin\$(Configuration)\ @@ -238,6 +239,7 @@ + @@ -278,6 +280,6 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/CefSharp.Core/CefSharp.Core.vcxproj.filters b/CefSharp.Core/CefSharp.Core.vcxproj.filters index 89d19da60..e1a242f19 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj.filters +++ b/CefSharp.Core/CefSharp.Core.vcxproj.filters @@ -121,6 +121,9 @@ Header Files + + Header Files + diff --git a/CefSharp.Core/Internals/AutoLock.h b/CefSharp.Core/Internals/AutoLock.h new file mode 100644 index 000000000..659f8a306 --- /dev/null +++ b/CefSharp.Core/Internals/AutoLock.h @@ -0,0 +1,58 @@ +#pragma once + +#include + +namespace CefSharp +{ + namespace Internals + { + private class CriticalSection + { + public: + CriticalSection() + { + ::InitializeCriticalSection(&_cs); + } + + ~CriticalSection() + { + ::DeleteCriticalSection(&_cs); + } + + void Enter() + { + ::EnterCriticalSection(&_cs); + } + void Leave() + { + ::LeaveCriticalSection(&_cs); + } + + private: + CriticalSection(const CriticalSection&); + CriticalSection& operator=(const CriticalSection&); + + CRITICAL_SECTION _cs; + }; + + private class AutoLock + { + public: + AutoLock(CriticalSection& cs) : _cs(cs) + { + _cs.Enter(); + } + + ~AutoLock() + { + _cs.Leave(); + } + + private: + AutoLock(const AutoLock&); + AutoLock& operator=(const AutoLock&); + + CriticalSection& _cs; + }; + }; +}; \ No newline at end of file diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index b8526f467..8cf9f81b4 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -60,7 +60,7 @@ namespace CefSharp handler->OnBeforeClose(_browserControl); } - _cefBrowser = nullptr; + _cefBrowser = NULL; } } @@ -163,7 +163,8 @@ namespace CefSharp return; } - AutoLock lock_scope(this); + AutoLock lock_scope(_syncRoot); + if (frame->IsMain()) { _browserControl->SetIsLoading(true); @@ -180,7 +181,8 @@ namespace CefSharp return; } - AutoLock lock_scope(this); + AutoLock lock_scope(_syncRoot); + if (frame->IsMain()) { _browserControl->SetIsLoading(false); diff --git a/CefSharp.Core/Internals/ClientAdapter.h b/CefSharp.Core/Internals/ClientAdapter.h index c5df134b0..c05b1d500 100644 --- a/CefSharp.Core/Internals/ClientAdapter.h +++ b/CefSharp.Core/Internals/ClientAdapter.h @@ -8,6 +8,7 @@ #include "include/cef_app.h" #include "include/cef_client.h" #include "include/cef_render_process_handler.h" +#include "AutoLock.h" using namespace System; @@ -29,7 +30,8 @@ namespace CefSharp public CefDialogHandler { private: - gcroot _browserControl; + CriticalSection _syncRoot; + gcroot _browserControl; gcroot^> _onAfterBrowserCreated; HWND _browserHwnd; CefRefPtr _cefBrowser; @@ -48,7 +50,7 @@ namespace CefSharp _browserControl = nullptr; _onAfterBrowserCreated = nullptr; _browserHwnd = nullptr; - _cefBrowser = nullptr; + _cefBrowser = NULL; _tooltip = nullptr; } @@ -117,7 +119,6 @@ namespace CefSharp const CefString& default_file_name, const std::vector& accept_types, CefRefPtr callback) OVERRIDE; - IMPLEMENT_LOCKING(ClientAdapter); IMPLEMENT_REFCOUNTING(ClientAdapter); }; } diff --git a/CefSharp.Core/Internals/CompletionHandler.h b/CefSharp.Core/Internals/CompletionHandler.h index a1d4d851d..6982d907b 100644 --- a/CefSharp.Core/Internals/CompletionHandler.h +++ b/CefSharp.Core/Internals/CompletionHandler.h @@ -9,7 +9,7 @@ namespace CefSharp { - private class CompletionHandler : public CefCompletionHandler + private class CompletionHandler : public CefCompletionCallback { private: gcroot _handler; diff --git a/CefSharp.Core/Internals/RenderClientAdapter.h b/CefSharp.Core/Internals/RenderClientAdapter.h index df5b95916..6d2ed2cf7 100644 --- a/CefSharp.Core/Internals/RenderClientAdapter.h +++ b/CefSharp.Core/Internals/RenderClientAdapter.h @@ -58,11 +58,9 @@ namespace CefSharp { return false; } - else - { - rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height); - return true; - } + + rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height); + return true; }; /// diff --git a/CefSharp.Core/Internals/StreamAdapter.cpp b/CefSharp.Core/Internals/StreamAdapter.cpp index adc1be635..d17553d91 100644 --- a/CefSharp.Core/Internals/StreamAdapter.cpp +++ b/CefSharp.Core/Internals/StreamAdapter.cpp @@ -16,7 +16,7 @@ namespace CefSharp size_t StreamAdapter::Read(void* ptr, size_t size, size_t n) { - AutoLock lock_scope(this); + AutoLock lock_scope(_syncRoot); try { array^ buffer = gcnew array(n * size); diff --git a/CefSharp.Core/Internals/StreamAdapter.h b/CefSharp.Core/Internals/StreamAdapter.h index 7f7bc3b7f..70c882389 100644 --- a/CefSharp.Core/Internals/StreamAdapter.h +++ b/CefSharp.Core/Internals/StreamAdapter.h @@ -3,6 +3,7 @@ // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #include "Stdafx.h" +#include "AutoLock.h" #pragma once using namespace System; @@ -14,6 +15,7 @@ namespace CefSharp { private class StreamAdapter : public CefReadHandler { + CriticalSection _syncRoot; gcroot _stream; public: @@ -25,7 +27,6 @@ namespace CefSharp virtual int64 Tell(); virtual int Eof(); - IMPLEMENT_LOCKING(StreamAdapter); IMPLEMENT_REFCOUNTING(StreamAdapter); }; } diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index 071677ba4..fac53f31d 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.h +++ b/CefSharp.Core/ManagedCefBrowserAdapter.h @@ -57,8 +57,7 @@ namespace CefSharp { HWND hwnd = HWND(); CefWindowInfo window; - window.SetAsOffScreen(hwnd); - window.SetTransparentPainting(true); + window.SetAsWindowless(hwnd, TRUE); CefString addressNative = StringUtils::ToNative("about:blank"); if (!CefBrowserHost::CreateBrowser(window, _renderClientAdapter.get(), addressNative, diff --git a/CefSharp.Core/SchemeHandlerWrapper.cpp b/CefSharp.Core/SchemeHandlerWrapper.cpp index 5d44aaa2b..d7902fa60 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.cpp +++ b/CefSharp.Core/SchemeHandlerWrapper.cpp @@ -36,7 +36,7 @@ namespace CefSharp bool handled = false; - AutoLock lock_scope(this); + AutoLock lock_scope(_syncRoot); auto schemeResponse = gcnew SchemeHandlerResponse(this); auto onRequestCompleted = gcnew OnRequestCompletedHandler(schemeResponse, &SchemeHandlerResponse::OnRequestCompleted); @@ -92,9 +92,9 @@ namespace CefSharp { bool has_data = false; - AutoLock lock_scope(this); + AutoLock lock_scope(_syncRoot); - if (!_stream) + if (static_cast(_stream) == nullptr) { bytes_read = 0; } @@ -118,17 +118,17 @@ namespace CefSharp void SchemeHandlerWrapper::Cancel() { - if (!!_stream && _closeStream) + if (static_cast(_stream) != nullptr && _closeStream) { _stream->Close(); } _stream = nullptr; - _callback = nullptr; + _callback = NULL; } int SchemeHandlerWrapper::SizeFromStream() { - if (!_stream) + if (static_cast(_stream) == nullptr) { return 0; } diff --git a/CefSharp.Core/SchemeHandlerWrapper.h b/CefSharp.Core/SchemeHandlerWrapper.h index 4f0939ba5..b1f349651 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.h +++ b/CefSharp.Core/SchemeHandlerWrapper.h @@ -6,6 +6,7 @@ #include "Stdafx.h" #include "include/cef_scheme.h" +#include "Internals/AutoLock.h" using namespace System; using namespace System::IO; @@ -17,6 +18,7 @@ namespace CefSharp public class SchemeHandlerWrapper : public CefResourceHandler { + CriticalSection _syncRoot; gcroot _handler; gcroot _stream; CefRefPtr _callback; @@ -33,7 +35,7 @@ namespace CefSharp SchemeHandlerWrapper(ISchemeHandler^ handler) : _handler(handler) { - if (!_handler) + if (static_cast(_handler) == nullptr) { throw gcnew ArgumentException("handler must not be null"); } @@ -45,7 +47,6 @@ namespace CefSharp virtual bool ReadResponse(void* data_out, int bytes_to_read, int& bytes_read, CefRefPtr callback); virtual void Cancel(); - IMPLEMENT_LOCKING(SchemeHandlerWrapper); IMPLEMENT_REFCOUNTING(SchemeHandlerWrapper); }; diff --git a/CefSharp.Core/Wrappers/CefSubprocessWrapper.h b/CefSharp.Core/Wrappers/CefSubprocessWrapper.h new file mode 100644 index 000000000..d1912affe --- /dev/null +++ b/CefSharp.Core/Wrappers/CefSubprocessWrapper.h @@ -0,0 +1,132 @@ +// Copyright © 2010-2014 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +#pragma once + +#include "include/cef_browser.h" +#include "include/cef_runnable.h" + +using namespace System::Threading; + +namespace CefSharp +{ + private class CefBrowserUnmanagedWrapper + { + CefRefPtr _cefBrowser; + + public: + gcroot WaitHandle; + gcroot EvaluateScriptResult; + gcroot EvaluateScriptExceptionMessage; + + CefBrowserUnmanagedWrapper(CefRefPtr cefBrowser) + { + _cefBrowser = cefBrowser; + WaitHandle = gcnew AutoResetEvent(false); + } + + ~CefBrowserUnmanagedWrapper() + { + _cefBrowser = NULL; + EvaluateScriptResult = nullptr; + EvaluateScriptExceptionMessage = nullptr; + + AutoResetEvent^ waithandle = WaitHandle; + WaitHandle = nullptr; + delete waithandle; + } + + void EvaluateScriptCallback(int64 frameId, CefString script, double timeout) + { + // TODO: Do something about the timeout... + + auto frame = _cefBrowser->GetFrame(frameId); + CefRefPtr context = frame->GetV8Context(); + + if (context.get() && context->Enter()) + { + EvaluateScriptInContext(context, script); + context->Exit(); + } + WaitHandle->Set(); + } + + void EvaluateScriptInContext(CefRefPtr context, CefString script) + { + CefRefPtr result; + CefRefPtr exception; + + EvaluateScriptExceptionMessage = nullptr; + + bool success = context->Eval(script, result, exception); + if (success) + { + try + { + EvaluateScriptResult = TypeUtils::ConvertFromCef(result); + } + catch (Exception^ ex) + { + EvaluateScriptExceptionMessage = ex->Message; + } + } + else if (exception.get()) + { + EvaluateScriptExceptionMessage = StringUtils::ToClr(exception->GetMessage()); + } + else + { + EvaluateScriptExceptionMessage = "Failed to evaluate script"; + } + } + + IMPLEMENT_REFCOUNTING(CefBrowserUnmanagedWrapper); + }; + + // "Master class" for wrapping everything that the CefSubprocess needs. + ref class CefBrowserWrapper : CefBrowserBase + { + MCefRefPtr _cefBrowser; + MCefRefPtr _unmanagedWrapper; + + public: + + CefBrowserWrapper(CefRefPtr cefBrowser) : + _cefBrowser(cefBrowser) + { + BrowserId = cefBrowser->GetIdentifier(); + _unmanagedWrapper = new CefBrowserUnmanagedWrapper(cefBrowser); + } + + virtual void DoDispose( bool disposing ) override + { + _cefBrowser = nullptr; + _unmanagedWrapper = nullptr; + CefBrowserBase::DoDispose( disposing ); + } + + virtual Object^ EvaluateScript(System::Int32 frameId, String^ script, double timeout) override + { + // TODO: Could we do something genericly useful here using C++ lambdas? To avoid having to make a lot of of these... + // TODO: DON'T USE AUTORESETEVENT STUPIDITY! Even though the code below compiles & runs correctly, it deadlocks the + // thread from which the request came, which is very, very stupid, especially since V8 and Chromium are built + // with asynchrony in mind. Instead, we should re-think this API to utilize WCF callbacks instead: + // http://idunno.org/archive/2008/05/29/wcf-callbacks-a-beginners-guide.aspx + // That feels much more like 2013, and not 1994... :) + // TODO: How about concurrency? One way to easily resolve it is to new() up something unique here and use that to + // invoke the method. + CefBrowserUnmanagedWrapper* unmanagedWrapper = _unmanagedWrapper.get(); + CefPostTask(TID_RENDERER, NewCefRunnableMethod(unmanagedWrapper, + &CefBrowserUnmanagedWrapper::EvaluateScriptCallback, frameId, StringUtils::ToNative(script), timeout)); + unmanagedWrapper->WaitHandle->WaitOne(); + + if (static_cast(unmanagedWrapper->EvaluateScriptExceptionMessage) != nullptr) + { + throw gcnew FaultException(unmanagedWrapper->EvaluateScriptExceptionMessage); + } + + return unmanagedWrapper->EvaluateScriptResult; + } + }; +} diff --git a/CefSharp.Core/packages.config b/CefSharp.Core/packages.config index bbef23d17..03ee03d3d 100644 --- a/CefSharp.Core/packages.config +++ b/CefSharp.Core/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CefSharp.Test/CefSharp.Test.csproj b/CefSharp.Test/CefSharp.Test.csproj index 832348299..f24312825 100644 --- a/CefSharp.Test/CefSharp.Test.csproj +++ b/CefSharp.Test/CefSharp.Test.csproj @@ -18,6 +18,8 @@ 3.5 Client + + 64eeb8eb true @@ -135,11 +137,13 @@ --> - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + \ No newline at end of file diff --git a/CefSharp.Test/packages.config b/CefSharp.Test/packages.config index 742fc0821..0f1da6083 100644 --- a/CefSharp.Test/packages.config +++ b/CefSharp.Test/packages.config @@ -2,7 +2,8 @@ - + + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj index cb5dfba97..b46a2bc08 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj @@ -20,6 +20,8 @@ 3.5 Client + + 251f73ac x64 @@ -69,7 +71,9 @@ BrowserTabUserControl.cs - + + Form + SimpleBrowserForm.cs @@ -142,11 +146,13 @@ - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/packages.config b/CefSharp.WinForms.Example/packages.config index b519c7ce7..711f25de0 100644 --- a/CefSharp.WinForms.Example/packages.config +++ b/CefSharp.WinForms.Example/packages.config @@ -1,4 +1,5 @@  - + + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index 084c53974..a8104f1f2 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -20,6 +20,8 @@ 3.5 Client + + 04d545b3 true @@ -159,11 +161,13 @@ - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/packages.config b/CefSharp.Wpf.Example/packages.config index b519c7ce7..711f25de0 100644 --- a/CefSharp.Wpf.Example/packages.config +++ b/CefSharp.Wpf.Example/packages.config @@ -1,4 +1,5 @@  - + + \ No newline at end of file diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 5e800ae28..ea434a5c2 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -437,11 +437,6 @@ namespace CefSharp.Wpf CleanupCommand = new DelegateCommand(Dispose); StopCommand = new DelegateCommand(Stop); - managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this); - managedCefBrowserAdapter.CreateOffscreenBrowser(BrowserSettings ?? new BrowserSettings()); - - disposables.Add(managedCefBrowserAdapter); - disposables.Add(new DisposableEventWrapper(this, ActualHeightProperty, OnActualSizeChanged)); disposables.Add(new DisposableEventWrapper(this, ActualWidthProperty, OnActualSizeChanged)); } @@ -451,6 +446,18 @@ namespace CefSharp.Wpf Dispose(false); } + private void CreateOffscreenBrowserWhenActualSizeChanged() + { + if (managedCefBrowserAdapter != null) + { + return; + } + managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this); + managedCefBrowserAdapter.CreateOffscreenBrowser(BrowserSettings ?? new BrowserSettings()); + + disposables.Add(managedCefBrowserAdapter); + } + private void UiThreadRunAsync(Action action, DispatcherPriority priority = DispatcherPriority.DataBind) { if (Dispatcher.CheckAccess()) @@ -465,6 +472,8 @@ namespace CefSharp.Wpf private void OnActualSizeChanged(object sender, EventArgs e) { + // Initialize RenderClientAdapter when WPF has calculated the actual size of current content. + CreateOffscreenBrowserWhenActualSizeChanged(); managedCefBrowserAdapter.WasResized(); } diff --git a/CefSharp/LogSeverity.cs b/CefSharp/LogSeverity.cs index b25fa7ec7..0974cc197 100644 --- a/CefSharp/LogSeverity.cs +++ b/CefSharp/LogSeverity.cs @@ -31,11 +31,6 @@ namespace CefSharp /// Error, - /// - /// ErrorReport logging - /// - ErrorReport, - /// /// Completely disable logging /// diff --git a/CefSharp/Properties/AssemblyInfo.cs b/CefSharp/Properties/AssemblyInfo.cs index b35156f55..e4d95c752 100644 --- a/CefSharp/Properties/AssemblyInfo.cs +++ b/CefSharp/Properties/AssemblyInfo.cs @@ -33,8 +33,8 @@ namespace CefSharp public const bool ComVisible = false; public const string AssemblyCompany = "The CefSharp Authors"; public const string AssemblyProduct = "CefSharp"; - public const string AssemblyVersion = "33.0.2"; - public const string AssemblyFileVersion = "33.0.2"; + public const string AssemblyVersion = "37.0.0.0"; + public const string AssemblyFileVersion = "37.0.0.0"; public const string AssemblyCopyright = "Copyright © The CefSharp Authors 2010-2014"; public const string CefSharpCoreProject = "CefSharp.Core, PublicKey=" + PublicKey; public const string CefSharpBrowserSubprocessProject = "CefSharp.BrowserSubprocess, PublicKey=" + PublicKey; diff --git a/CefSharp3.sln b/CefSharp3.sln index f4bf45adc..e4dd53bea 100644 --- a/CefSharp3.sln +++ b/CefSharp3.sln @@ -63,6 +63,11 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{9F4008EF-0182-48C6-B0E8-972252DC3F72}" ProjectSection(SolutionItems) = preProject .nuget\packages.config = .nuget\packages.config +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D62CBBCA-9C35-4CB4-BA62-ADC79C9045DF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{9AD9C469-B121-47BB-9B9F-30D1B96B52B0}" + ProjectSection(SolutionItems) = preProject + build.ps1 = build.ps1 EndProjectSection EndProject Global @@ -201,5 +206,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {A23AA466-1903-44F2-946D-25AD0500D56B} = {47D0DC8C-D707-4D8A-A578-7737AA9CE79B} + {9AD9C469-B121-47BB-9B9F-30D1B96B52B0} = {47D0DC8C-D707-4D8A-A578-7737AA9CE79B} EndGlobalSection EndGlobal diff --git a/NuGet/CefSharp.Common.nuspec b/NuGet/CefSharp.Common.nuspec index fcc5b2ce7..424648e4d 100644 --- a/NuGet/CefSharp.Common.nuspec +++ b/NuGet/CefSharp.Common.nuspec @@ -12,9 +12,12 @@ chrome browser Copyright © 2010-2014 The CefSharp Authors - + + + + - + diff --git a/afterbuild.example.ps1 b/afterbuild.example.ps1 new file mode 100644 index 000000000..a862e42d9 --- /dev/null +++ b/afterbuild.example.ps1 @@ -0,0 +1,32 @@ +param( + [Parameter(Position = 0, Mandatory = $true)] + [string] $Version +) + +$WorkingDir = Split-Path -Parent $MyInvocation.MyCommand.Definition +$Nuget = Join-Path $env:LOCALAPPDATA .\nuget\NuGet.exe +$PackagePath = Join-Path $WorkingDir\nuget + +function Write-Diagnostic +{ + param( + [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)] + [string] $Message + ) + + Write-Host + Write-Host $Message -ForegroundColor Green + Write-Host +} + +Write-Diagnostic "Uploading packages to myget" + +$Packages = @( + "$PackagePath\CefSharp.Common.$Version.nupkg", + "$PackagePath\CefSharp.WinForms.$Version.nupkg", + "$PackagePath\CefSharp.Wpf.$Version.nupkg" +) + +$Packages | ForEach-Object { + . $Nuget push $_ -Source https://myget.org/F/X +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 70134c446..7309ebd25 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,9 @@ param( [Parameter(Position = 0)] [string] $Target = "nupkg", [Parameter(Position = 1)] - [string] $Version = "33.1.0-pre01" + [string] $Version = "37.0.0-pre02", + [Parameter(Position = 2)] + [string] $RedistVersion = "3.2062.1876" ) $WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition @@ -217,9 +219,16 @@ function Nupkg Write-Diagnostic "Building nuget package" # Build packages - . $nuget pack nuget\CefSharp.Common.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget + . $nuget pack nuget\CefSharp.Common.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget -Properties "RedistVersion=$RedistVersion" . $nuget pack nuget\CefSharp.Wpf.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget . $nuget pack nuget\CefSharp.WinForms.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget + + # Invoke `AfterBuild` script if available (ie. upload packages to myget) + if(-not (Test-Path $WorkingDir\AfterBuild.ps1)) { + return + } + + . $WorkingDir\AfterBuild.ps1 -Version $Version } function DownloadNuget() @@ -232,10 +241,25 @@ function DownloadNuget() } } +function WriteAssemblyVersion +{ + param() + + $Filename = Join-Path $WorkingDir CefSharp\Properties\AssemblyInfo.cs + $Regex = 'public const string AssemblyVersion = "(.*)"'; + + $AssemblyInfo = Get-Content $Filename + $NewString = $AssemblyInfo -replace $Regex, "public const string AssemblyVersion = ""$Version""" + + $NewString | Set-Content $Filename -Encoding UTF8 +} + DownloadNuget NugetPackageRestore +WriteAssemblyVersion + switch -Exact ($Target) { "nupkg" {