Skip to content

Commit

Permalink
fixes for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-b-novikov committed Jan 12, 2019
1 parent 3259724 commit c21619f
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,4 @@ docplan.txt
/Reinforced.Typings.Integrate/Reinforced.snk

\.idea/
/package
78 changes: 60 additions & 18 deletions Reinforced.Typings.Cli/AssemblyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand All @@ -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();
}

Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -205,6 +244,7 @@ private string[] LookupAssemblyPathInternal(string assemblyNameOrFullPath, bool
return possiblePathes;
}

List<string> result = new List<string>();
foreach (var dir in _allAssembliesDirs)
{
var p = Path.Combine(dir, assemblyNameOrFullPath);
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Reinforced.Typings.Cli/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions Reinforced.Typings.Cli/Reinforced.Typings.Cli.NETCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp2.2</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>Reinforced.Typings.Cli</RootNamespace>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
Expand All @@ -15,9 +15,9 @@
<Company>Reinforced Software Construction OSS</Company>
<Copyright>Pavel B. Novikov 2019</Copyright>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<AssemblyVersion>1.5</AssemblyVersion>
<FileVersion>1.5</FileVersion>
<InformationalVersion>1.5</InformationalVersion>
<AssemblyVersion>1.5.1</AssemblyVersion>
<FileVersion>1.5.1</FileVersion>
<InformationalVersion>1.5.1</InformationalVersion>
<DefineConstants>$(DefineConstants);$(RtAdditionalConstants);</DefineConstants>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@
<Company>Reinforced Software Construction OSS</Company>
<Copyright>Pavel B. Novikov 2019</Copyright>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<AssemblyVersion>1.5</AssemblyVersion>
<FileVersion>1.5</FileVersion>
<InformationalVersion>1.5</InformationalVersion>
<AssemblyVersion>1.5.1</AssemblyVersion>
<FileVersion>1.5.1</FileVersion>
<InformationalVersion>1.5.1</InformationalVersion>
<DefineConstants>$(DefineConstants);$(RtAdditionalConstants);</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='netstandard1.6'">
<DefineConstants>NETCORE1;</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions Reinforced.Typings.Integrate/RtCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions Reinforced.Typings/Reinforced.Typings.NETCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<TargetFramework>net461</TargetFramework>
<RootNamespace>Reinforced.Typings</RootNamespace>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand All @@ -12,9 +12,9 @@
<Company>Reinforced Software Construction OSS</Company>
<Copyright>Pavel B. Novikov 2019</Copyright>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<AssemblyVersion>1.5</AssemblyVersion>
<FileVersion>1.5</FileVersion>
<InformationalVersion>1.5</InformationalVersion>
<AssemblyVersion>1.5.1</AssemblyVersion>
<FileVersion>1.5.1</FileVersion>
<InformationalVersion>1.5.1</InformationalVersion>
<DefineConstants>$(DefineConstants);$(RtAdditionalConstants);</DefineConstants>
</PropertyGroup>
<ItemGroup>
Expand Down
28 changes: 21 additions & 7 deletions cake/build.cake
Original file line number Diff line number Diff line change
@@ -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(() =>
Expand Down Expand Up @@ -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<string>(new[]{NETSTANDARD15,NETSTANDARD16,NETSTANDARD20,NETCORE10,NETCORE11,NETCORE20,NETCORE21,NETCORE22});
var netCore = new HashSet<string>(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;.]*</{tfParameter}>";
const string tfSingleParameter = "TargetFramework";
string tfsRgx = $"<{tfSingleParameter}>[a-zA-Z0-9;.]*</{tfSingleParameter}>";

Task("PackageClean")
.Description("Cleaning temporary package folder")
Expand Down Expand Up @@ -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
});

}
Expand All @@ -97,7 +108,9 @@ Task("Build")
Information("---------");

ReplaceRegexInFiles(CliNetCoreProject,tfRgx,$"<{tfParameter}>{fw}</{tfParameter}>");
ReplaceRegexInFiles(RtNetCoreProject,tfRgx,$"<{tfParameter}>{fw}</{tfParameter}>");
ReplaceRegexInFiles(RtNetCoreProject,tfRgx,$"<{tfParameter}>{fw}</{tfParameter}>");
ReplaceRegexInFiles(CliNetCoreProject,tfsRgx,$"<{tfSingleParameter}>{fw}</{tfSingleParameter}>");
ReplaceRegexInFiles(RtNetCoreProject,tfsRgx,$"<{tfSingleParameter}>{fw}</{tfSingleParameter}>");

DotNetCoreMSBuildSettings mbs = null;

Expand All @@ -123,7 +136,8 @@ Task("Build")
Information("---------");

ReplaceRegexInFiles(RtNetCoreProject,tfRgx,$"<{tfParameter}>{fw}</{tfParameter}>");

ReplaceRegexInFiles(RtNetCoreProject,tfsRgx,$"<{tfSingleParameter}>{fw}</{tfSingleParameter}>");

var mbs = new DotNetCoreMSBuildSettings()
.WithProperty("DocumentationFile",$@"bin\Release\{fw}\Reinforced.Typings.xml");

Expand Down
13 changes: 4 additions & 9 deletions package/Reinforced.Typings.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Reinforced.Typings</id>
<version>1.5</version>
<version>1.5.1</version>
<title>Reinforced.Typings</title>
<authors>Pavel B. Novikov and contributors</authors>
<owners>Pavel B. Novikov</owners>
Expand All @@ -16,14 +16,9 @@
<tags>mvc, web, typescript</tags>
<license type="file">license\license.txt</license>
<releaseNotes>
- MSBuild behavior fixes
- ReferenceProcessor
- ReorderMembers
- ThirdParty attribute
- Fluent configuration refactoring
- Constructors generation
- ForceNullable behavior revised
- Lots of bugfixes

- MacOS/Linux fixes

</releaseNotes>
<dependencies>
<group targetFramework=".NETFramework4.5" />
Expand Down
2 changes: 2 additions & 0 deletions stuff/Reinforced.Typings.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<tags>mvc, web, typescript</tags>
<license type="file">license\license.txt</license>
<releaseNotes>

$$RELNOTES$$

</releaseNotes>
<dependencies>
<group targetFramework=".NETFramework4.5" />
Expand Down
1 change: 1 addition & 0 deletions stuff/relnotes/1.5.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- MacOS/Linux fixes

0 comments on commit c21619f

Please sign in to comment.