diff --git a/CK.Core/CK.Core.csproj b/CK.Core/CK.Core.csproj index 2233886d..5da94371 100644 --- a/CK.Core/CK.Core.csproj +++ b/CK.Core/CK.Core.csproj @@ -9,7 +9,7 @@ - + diff --git a/CK.Core/FileUtil.cs b/CK.Core/FileUtil.cs index 8db13d0f..7030fd1f 100644 --- a/CK.Core/FileUtil.cs +++ b/CK.Core/FileUtil.cs @@ -67,12 +67,12 @@ static public string NormalizePathSeparator( string path, bool ensureTrailingBac /// /// Gets the as a string. /// - public static readonly string DirectorySeparatorString = new String( Path.DirectorySeparatorChar, 1 ); + public static readonly string DirectorySeparatorString = NormalizedPath.DirectorySeparatorString; /// /// Gets the as a string. /// - public static readonly string AltDirectorySeparatorString = new String( Path.AltDirectorySeparatorChar, 1 ); + public static readonly string AltDirectorySeparatorString = NormalizedPath.AltDirectorySeparatorString; /// /// A display format for that supports round-trips, is readable and can be used in path diff --git a/CK.Core/WeakAssemblyNameResolver.cs b/CK.Core/WeakAssemblyNameResolver.cs new file mode 100644 index 00000000..072e13c1 --- /dev/null +++ b/CK.Core/WeakAssemblyNameResolver.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; + +namespace CK.Core +{ + + /// + /// Assemby loader helper: hooks the event + /// in order to try to load a version-less assembly. + /// The is maintained and can be used to diagnose any assembly binding issues. + /// All members are thread safe. + /// + public static class WeakAssemblyNameResolver + { + static int _installCount; + static List> _list = new List>(); + + /// + /// Gets whether this helper is active. + /// + public static bool IsInstalled => _installCount >= 0; + + /// + /// Installs the hook if not already installed. + /// Instead of using Install/, the helper should be used. + /// + public static void Install() + { + if( Interlocked.Increment( ref _installCount ) == 1 ) + { + AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; + } + } + + /// + /// Uninstall the hook if possible. + /// + public static void Uninstall() + { + if( Interlocked.Decrement( ref _installCount ) == 0 ) + { + AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve; + } + } + + /// + /// Gets the pair of requested name and eventually resolved name that have been resolved so far. + /// + /// A copy of the internally maintained list of resolved assembly names. + public static KeyValuePair[] GetResolvedList() + { + lock( _list ) + { + return _list.ToArray(); + } + } + + class Auto : IDisposable + { + bool _done; + + public void Dispose() + { + if( !_done ) + { + _done = true; + Uninstall(); + } + } + } + + /// + /// Temporary installs the hook that will be uninstalled when the returned object will be disposed. + /// + /// The dispoable to dispose when done. + public static IDisposable TemporaryInstall() + { + Install(); + return new Auto(); + } + + static Assembly CurrentDomain_AssemblyResolve( object sender, ResolveEventArgs args ) + { + var failed = new AssemblyName( args.Name ); + var resolved = failed.Version != null && string.IsNullOrWhiteSpace( failed.CultureName ) + ? Assembly.Load( new AssemblyName( failed.Name ) ) + : null; + lock( _list ) + { + _list.Add( new KeyValuePair( failed, resolved?.GetName() ) ); + } + return resolved; + } + } +} diff --git a/CodeCakeBuilder/Build.cs b/CodeCakeBuilder/Build.cs index 12e0433e..0a957f1d 100644 --- a/CodeCakeBuilder/Build.cs +++ b/CodeCakeBuilder/Build.cs @@ -182,7 +182,7 @@ public Build() || gitInfo.PreReleaseName == "prerelease" || gitInfo.PreReleaseName == "rc" ) { - PushNuGetPackages( "NUGET_API_KEY", "https://www.nuget.org/api/v2/package", nugetPackages ); + PushNuGetPackages( "MYGET_RELEASE_API_KEY", "https://www.myget.org/F/invenietis-preview/api/v2/package", nugetPackages ); } else { diff --git a/CodeCakeBuilder/CodeCakeBuilder.csproj b/CodeCakeBuilder/CodeCakeBuilder.csproj index b93fd1c0..07253a62 100644 --- a/CodeCakeBuilder/CodeCakeBuilder.csproj +++ b/CodeCakeBuilder/CodeCakeBuilder.csproj @@ -1,6 +1,6 @@  - + Debug @@ -37,27 +37,26 @@ 4 - - ..\packages\Cake.Common.0.22.0\lib\net46\Cake.Common.dll + + ..\packages\Cake.Common.0.23.0\lib\net46\Cake.Common.dll - - ..\packages\Cake.Core.0.22.0\lib\net46\Cake.Core.dll + + ..\packages\Cake.Core.0.23.0\lib\net46\Cake.Core.dll - - ..\packages\CK.Text.6.0.1\lib\net461\CK.Text.dll + + ..\packages\CK.Text.6.1.0\lib\net461\CK.Text.dll - - ..\packages\Code.Cake.0.15.0\lib\net45\Code.Cake.dll - True + + ..\packages\Code.Cake.0.18.0\lib\net45\Code.Cake.dll - - ..\packages\CSemVer.1.0.1\lib\net461\CSemVer.dll + + ..\packages\CSemVer.1.1.0\lib\net461\CSemVer.dll - - ..\packages\SimpleGitVersion.Cake.0.28.0\lib\net45\SimpleGitVersion.Cake.dll + + ..\packages\SimpleGitVersion.Cake.0.30.0\lib\net45\SimpleGitVersion.Cake.dll - - ..\packages\SimpleGitVersion.Core.0.28.0\lib\net45\SimpleGitVersion.Core.dll + + ..\packages\SimpleGitVersion.Core.0.30.0\lib\net45\SimpleGitVersion.Core.dll @@ -77,7 +76,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - +