diff --git a/.gitignore b/.gitignore index 4821f437..6cd3d387 100644 --- a/.gitignore +++ b/.gitignore @@ -217,3 +217,4 @@ docplan.txt /Reinforced.Typings.Integrate/Reinforced.snk \.idea/ +/package diff --git a/Reinforced.Typings.Cli/AssemblyManager.cs b/Reinforced.Typings.Cli/AssemblyManager.cs index cae73087..823f8440 100644 --- a/Reinforced.Typings.Cli/AssemblyManager.cs +++ b/Reinforced.Typings.Cli/AssemblyManager.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Linq.Expressions; using System.Reflection; #if NETCORE using System.Runtime.Loader; @@ -45,6 +46,15 @@ public AssemblyManager(string[] sourceAssemblies, TextReader profileReader, stri BuildWarn = buildWarn; } + internal void TurnOffAdditionalResolvation() + { +#if NETCORE + AssemblyLoadContext.Default.Resolving -= CurrentDomainOnAssemblyResolve; +#else + AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainOnAssemblyResolve; + +#endif + } public Assembly[] GetAssembliesFromArgs() { @@ -63,20 +73,29 @@ public Assembly[] GetAssembliesFromArgs() var pathes = LookupPossibleAssemblyPath(assemblyPath); foreach (var path in pathes) { - if (path == assemblyPath) + if (!Path.IsPathRooted(assemblyPath)) { BuildWarn("Assembly {0} may be resolved incorrectly", new object[] { assemblyPath }); } + + try + { #if NETCORE - var a = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); + var a = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); #else - var a = Assembly.LoadFrom(path); + var a = Assembly.LoadFrom(path); #endif - _totalLoadedAssemblies++; - assemblies.Add(a); + _totalLoadedAssemblies++; + assemblies.Add(a); + } + catch (Exception ex) + { + BuildWarn("Assembly {0} failed to load: {1}", new object[] { path, ex }); + } } } + return assemblies.ToArray(); } @@ -122,15 +141,24 @@ private Assembly CurrentDomainOnAssemblyResolve(AssemblyLoadContext context, Ass Assembly a = null; foreach (var path in paths) { - if (path != nm.Name) a = context.LoadFromAssemblyPath(path); - else BuildWarn("Assembly {0} may be resolved incorrectly", new object[] { nm.Name }); - - if (a != null) + try { - _alreadyLoaded[assemblyName.FullName] = a; - _totalLoadedAssemblies++; + if (!Path.IsPathRooted(path)) + { + BuildWarn("Assembly {0} may be resolved incorrectly to {1}", new object[] { nm.Name, path }); + continue; + } + a = context.LoadFromAssemblyPath(path); + } + catch (Exception ex) + { + BuildWarn("Assembly {0} from {1} was not loaded: {2}", new object[] { nm.Name, path, ex }); + continue; } + _alreadyLoaded[assemblyName.FullName] = a; + _totalLoadedAssemblies++; + #if DEBUG Console.WriteLine("{0} additionally resolved", nm); #endif @@ -149,14 +177,25 @@ private Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs Assembly a = null; foreach (var path in paths) { - if (path != nm.Name) a = Assembly.LoadFrom(path); - else BuildWarn("Assembly {0} may be resolved incorrectly", new object[] { nm.Name }); - - if (a != null) + try { - _alreadyLoaded[args.Name] = a; - _totalLoadedAssemblies++; + if (!Path.IsPathRooted(path)) + { + BuildWarn("Assembly {0} may be resolved incorrectly to {1}", new object[] { nm.Name, path }); + continue; + } + + a = Assembly.LoadFrom(path); + } + catch (Exception ex) + { + BuildWarn("Assembly {0} from {1} was not loaded: {2}", new object[] { nm.Name, path, ex }); + continue; } + + + _alreadyLoaded[args.Name] = a; + _totalLoadedAssemblies++; #if DEBUG Console.WriteLine("{0} additionally resolved", nm); @@ -205,6 +244,7 @@ private string[] LookupAssemblyPathInternal(string assemblyNameOrFullPath, bool return possiblePathes; } + List result = new List(); foreach (var dir in _allAssembliesDirs) { var p = Path.Combine(dir, assemblyNameOrFullPath); @@ -213,10 +253,12 @@ private string[] LookupAssemblyPathInternal(string assemblyNameOrFullPath, bool #if DEBUG Console.WriteLine("Assembly {0} found at {1}", assemblyNameOrFullPath, p); #endif - return new[] { p }; + result.Add(p); } } + if (result.Count > 0) return result.ToArray(); + return null; } diff --git a/Reinforced.Typings.Cli/Bootstrapper.cs b/Reinforced.Typings.Cli/Bootstrapper.cs index 4de254b0..ca1305f6 100644 --- a/Reinforced.Typings.Cli/Bootstrapper.cs +++ b/Reinforced.Typings.Cli/Bootstrapper.cs @@ -99,6 +99,7 @@ public static void Main(string[] args) ResolveFluentMethod(settings); TsExporter exporter = new TsExporter(settings); exporter.Export(); + _assemblyManager.TurnOffAdditionalResolvation(); foreach (var rtWarning in settings.Warnings) { var msg = VisualStudioFriendlyErrorMessage.Create(rtWarning); diff --git a/Reinforced.Typings.Cli/Reinforced.Typings.Cli.NETCore.csproj b/Reinforced.Typings.Cli/Reinforced.Typings.Cli.NETCore.csproj index 28847203..3dedc647 100644 --- a/Reinforced.Typings.Cli/Reinforced.Typings.Cli.NETCore.csproj +++ b/Reinforced.Typings.Cli/Reinforced.Typings.Cli.NETCore.csproj @@ -1,6 +1,6 @@ - netcoreapp2.2 + netcoreapp2.2 Exe Reinforced.Typings.Cli false @@ -15,9 +15,9 @@ Reinforced Software Construction OSS Pavel B. Novikov 2019 $(AssemblyName) - 1.5 - 1.5 - 1.5 + 1.5.1 + 1.5.1 + 1.5.1 $(DefineConstants);$(RtAdditionalConstants); diff --git a/Reinforced.Typings.Integrate/Reinforced.Typings.Integrate.NETCore.csproj b/Reinforced.Typings.Integrate/Reinforced.Typings.Integrate.NETCore.csproj index 0b90fe36..582e25c6 100644 --- a/Reinforced.Typings.Integrate/Reinforced.Typings.Integrate.NETCore.csproj +++ b/Reinforced.Typings.Integrate/Reinforced.Typings.Integrate.NETCore.csproj @@ -11,15 +11,12 @@ Reinforced Software Construction OSS Pavel B. Novikov 2019 $(AssemblyName) - 1.5 - 1.5 - 1.5 + 1.5.1 + 1.5.1 + 1.5.1 $(DefineConstants);$(RtAdditionalConstants); - - NETCORE1; - diff --git a/Reinforced.Typings.Integrate/RtCli.cs b/Reinforced.Typings.Integrate/RtCli.cs index 44880960..514a5308 100644 --- a/Reinforced.Typings.Integrate/RtCli.cs +++ b/Reinforced.Typings.Integrate/RtCli.cs @@ -151,9 +151,10 @@ private bool IsCore { get { - if (string.IsNullOrEmpty(TargetFramework)) return false; - if (TargetFramework.StartsWith("netstandard")) return true; - if (TargetFramework.StartsWith("netcoreapp")) return true; + var fw = NormalizeFramework(); + if (string.IsNullOrEmpty(fw)) return false; + if (fw.StartsWith("netstandard")) return true; + if (fw.StartsWith("netcoreapp")) return true; return false; } } diff --git a/Reinforced.Typings/Reinforced.Typings.NETCore.csproj b/Reinforced.Typings/Reinforced.Typings.NETCore.csproj index bc6d1015..84cb793b 100644 --- a/Reinforced.Typings/Reinforced.Typings.NETCore.csproj +++ b/Reinforced.Typings/Reinforced.Typings.NETCore.csproj @@ -1,6 +1,6 @@ - net461 + net461 Reinforced.Typings false false @@ -12,9 +12,9 @@ Reinforced Software Construction OSS Pavel B. Novikov 2019 $(AssemblyName) - 1.5 - 1.5 - 1.5 + 1.5.1 + 1.5.1 + 1.5.1 $(DefineConstants);$(RtAdditionalConstants); diff --git a/cake/build.cake b/cake/build.cake index a306e2aa..595491be 100644 --- a/cake/build.cake +++ b/cake/build.cake @@ -1,6 +1,6 @@ #addin "Cake.FileHelpers" var target = Argument("target", "Build"); -const string version = "1.5"; +const string version = "1.5.1"; Task("Clean") .Does(() => @@ -35,13 +35,15 @@ var cliFrameworks = new[] { NETCORE10, NETCORE11, NET45, NET461,NETCORE20,NETCOR var rtFrameworks = new[] { NETCORE10, NETCORE11, NETSTANDARD15,NETSTANDARD20,NETCORE20,NETCORE21,NETCORE22,NET45, NET461}; var taskFrameworks = new[] { NET46, NETSTANDARD20}; -var netCore = new HashSet(new[]{NETSTANDARD15,NETSTANDARD16,NETSTANDARD20,NETCORE10,NETCORE11,NETCORE20,NETCORE21,NETCORE22}); +var netCore = new HashSet(new[]{NETSTANDARD15,NETSTANDARD20,NETCORE10,NETCORE11,NETCORE20,NETCORE21,NETCORE22}); const string CliNetCoreProject = "../Reinforced.Typings.Cli/Reinforced.Typings.Cli.NETCore.csproj"; const string RtNetCoreProject = "../Reinforced.Typings/Reinforced.Typings.NETCore.csproj"; const string IntegrateProject = "../Reinforced.Typings.Integrate/Reinforced.Typings.Integrate.NETCore.csproj"; const string tfParameter = "TargetFrameworks"; string tfRgx = $"<{tfParameter}>[a-zA-Z0-9;.]*"; +const string tfSingleParameter = "TargetFramework"; +string tfsRgx = $"<{tfSingleParameter}>[a-zA-Z0-9;.]*"; Task("PackageClean") .Description("Cleaning temporary package folder") @@ -72,11 +74,20 @@ Task("BuildIntegrate") .Description("Building RT's integration MSBuild task") .Does(()=>{ foreach(var fw in taskFrameworks){ - DotNetCoreBuild(IntegrateProject, new DotNetCoreBuildSettings + DotNetCoreMSBuildSettings mbs = null; + + if (netCore.Contains(fw)){ + mbs = new DotNetCoreMSBuildSettings() + .WithProperty("RtAdditionalConstants","NETCORE;" + fw.ToUpperInvariant().Replace(".","_")) + .WithProperty("RtNetCore","True"); + } + DotNetCorePublish(IntegrateProject, new DotNetCorePublishSettings { Verbosity = DotNetCoreVerbosity.Quiet, - Configuration = RELEASE, - OutputDirectory = System.IO.Path.Combine(buildPath, fw) + Configuration = RELEASE, + MSBuildSettings = mbs, + OutputDirectory = System.IO.Path.Combine(buildPath, fw), + Framework = fw }); } @@ -97,7 +108,9 @@ Task("Build") Information("---------"); ReplaceRegexInFiles(CliNetCoreProject,tfRgx,$"<{tfParameter}>{fw}"); - ReplaceRegexInFiles(RtNetCoreProject,tfRgx,$"<{tfParameter}>{fw}"); + ReplaceRegexInFiles(RtNetCoreProject,tfRgx,$"<{tfParameter}>{fw}"); + ReplaceRegexInFiles(CliNetCoreProject,tfsRgx,$"<{tfSingleParameter}>{fw}"); + ReplaceRegexInFiles(RtNetCoreProject,tfsRgx,$"<{tfSingleParameter}>{fw}"); DotNetCoreMSBuildSettings mbs = null; @@ -123,7 +136,8 @@ Task("Build") Information("---------"); ReplaceRegexInFiles(RtNetCoreProject,tfRgx,$"<{tfParameter}>{fw}"); - + ReplaceRegexInFiles(RtNetCoreProject,tfsRgx,$"<{tfSingleParameter}>{fw}"); + var mbs = new DotNetCoreMSBuildSettings() .WithProperty("DocumentationFile",$@"bin\Release\{fw}\Reinforced.Typings.xml"); diff --git a/package/Reinforced.Typings.nuspec b/package/Reinforced.Typings.nuspec index 253decdd..8bf8b212 100644 --- a/package/Reinforced.Typings.nuspec +++ b/package/Reinforced.Typings.nuspec @@ -2,7 +2,7 @@ Reinforced.Typings - 1.5 + 1.5.1 Reinforced.Typings Pavel B. Novikov and contributors Pavel B. Novikov @@ -16,14 +16,9 @@ mvc, web, typescript license\license.txt -- MSBuild behavior fixes -- ReferenceProcessor -- ReorderMembers -- ThirdParty attribute -- Fluent configuration refactoring -- Constructors generation -- ForceNullable behavior revised -- Lots of bugfixes + +- MacOS/Linux fixes + diff --git a/stuff/Reinforced.Typings.nuspec b/stuff/Reinforced.Typings.nuspec index eb7f572b..0833647a 100644 --- a/stuff/Reinforced.Typings.nuspec +++ b/stuff/Reinforced.Typings.nuspec @@ -16,7 +16,9 @@ mvc, web, typescript license\license.txt + $$RELNOTES$$ + diff --git a/stuff/relnotes/1.5.1.md b/stuff/relnotes/1.5.1.md new file mode 100644 index 00000000..f99e807d --- /dev/null +++ b/stuff/relnotes/1.5.1.md @@ -0,0 +1 @@ +- MacOS/Linux fixes \ No newline at end of file