Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (or workaround?) for codegen using netcore/netstandard 2.1 #4673

Merged
merged 7 commits into from Jun 13, 2018
Copy path View file
@@ -23,7 +23,7 @@
<!-- Common compile parameters -->
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);1591</NoWarn>
<NoWarn>$(NoWarn);1591;2003</NoWarn>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<!-- We use full (Windows PDBs) until cross platform support for source link will get better -->
<DebugType>full</DebugType>
Copy path View file
@@ -1 +1 @@
2.0.3
2.1.300
Copy path View file
@@ -8,20 +8,14 @@ set /p REQUIRED_DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt"

echo .Net Core version required: %REQUIRED_DOTNET_VERSION%

for /f "tokens=1 delims=. " %%a in ("%REQUIRED_DOTNET_VERSION%") do set REQUIRED_DOTNET_VERSION_MAJOR=%%a

for /f "tokens=*" %%i in ('where dotnet.exe') do (
set INSTALLED_DOTNET_EXE=%%i

echo Found dotnet.exe at: "!INSTALLED_DOTNET_EXE!"

for /f "tokens=*" %%j in ('"!INSTALLED_DOTNET_EXE!" --version') do set INSTALLED_DOTNET_VERSION=%%j

if [!INSTALLED_DOTNET_VERSION!] neq [] (
for /f "tokens=1 delims=. " %%a in ("!INSTALLED_DOTNET_VERSION!") do set INSTALLED_DOTNET_VERSION_MAJOR=%%a
)

if [!REQUIRED_DOTNET_VERSION_MAJOR!]==[!INSTALLED_DOTNET_VERSION_MAJOR!] (
if [!REQUIRED_DOTNET_VERSION!]==[!INSTALLED_DOTNET_VERSION!] (

echo .Net Core major version is matching !INSTALLED_DOTNET_VERSION!, using the installed version.

Copy path View file
@@ -16,7 +16,7 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

DOCKER_IMAGENAME=microsoft/dotnet:2.0.3-sdk
DOCKER_IMAGENAME=microsoft/dotnet:2.1.300-sdk

# $args array may have empty elements in it.
# The easiest way to remove them is to cast to string and back to array.
@@ -7,7 +7,7 @@
using Microsoft.Extensions.DependencyModel;
using Microsoft.Extensions.DependencyModel.Resolution;
using Orleans.Runtime;
#if NETCOREAPP2_0
#if NETCOREAPP
using System.Runtime.Loader;
#endif

@@ -28,7 +28,7 @@ internal class AssemblyResolver

private readonly DependencyContext dependencyContext;
private readonly DependencyContext resolverRependencyContext;
#if NETCOREAPP2_0
#if NETCOREAPP
private readonly AssemblyLoadContext loadContext;
#endif

@@ -53,7 +53,7 @@ public AssemblyResolver(string path, List<string> referencedAssemblies, bool ins
new PackageCompilationAssemblyResolver()
});

#if NETCOREAPP2_0
#if NETCOREAPP
this.loadContext = AssemblyLoadContext.GetLoadContext(this.Assembly);

if (this.loadContext == AssemblyLoadContext.Default)
@@ -87,7 +87,7 @@ public AssemblyResolver(string path, List<string> referencedAssemblies, bool ins

public void Dispose()
{
#if NETCOREAPP2_0
#if NETCOREAPP

if (this.loadContext == AssemblyLoadContext.Default)
{
@@ -120,7 +120,7 @@ public Assembly ResolveAssembly(object sender, ResolveEventArgs args)
{
var context = default(AssemblyLoadContext);

#if NETCOREAPP2_0
#if NETCOREAPP
context = AssemblyLoadContext.GetLoadContext(args.RequestingAssembly);
#endif

@@ -185,7 +185,7 @@ private Assembly TryLoadAssemblyFromPath(string path)
{
try
{
#if NETCOREAPP2_0
#if NETCOREAPP
return this.loadContext.LoadFromAssemblyPath(path);
#else
return Assembly.LoadFrom(path);
@@ -197,7 +197,7 @@ private Assembly TryLoadAssemblyFromPath(string path)
}
}

#if !NETCOREAPP2_0
#if !NETCOREAPP
internal class AssemblyLoadContext
{
}
@@ -8,7 +8,7 @@
using Orleans.Serialization;
using Orleans.Runtime;
using Orleans.Metadata;
#if NETCOREAPP2_0
#if NETCOREAPP
using System.Runtime.Loader;
#endif

@@ -44,7 +44,7 @@ public static bool GenerateCode(CodeGenOptions options)
// Generate source
Console.WriteLine($"Orleans-CodeGen - Generating file {outputFileName}");

#if !NETCOREAPP2_0
#if !NETCOREAPP
var generatedCode = GenerateCodeInAppDomain(options);
#else
var generatedCode = GenerateCodeInternal(options);
@@ -96,7 +96,7 @@ private static void SetupDepsFilesForAppDomain(AppDomain appDomain, FileInfo inp
}
}

#if !NETCOREAPP2_0
#if !NETCOREAPP
private static string GenerateCodeInAppDomain(CodeGenOptions options)
{
AppDomain appDomain = null;
@@ -150,7 +150,7 @@ private static string GenerateCodeInternal(CodeGenOptions options)
try
{
// Set up assembly resolution.
#if NETCOREAPP2_0
#if NETCOREAPP
AssemblyLoadContext.Default.Resolving += refResolver.AssemblyLoadContextResolving;
#else
AppDomain.CurrentDomain.AssemblyResolve += refResolver.ResolveAssembly;
@@ -161,7 +161,7 @@ private static string GenerateCodeInternal(CodeGenOptions options)
finally
{
refResolver.Dispose();
#if NETCOREAPP2_0
#if NETCOREAPP
AssemblyLoadContext.Default.Resolving -= refResolver.AssemblyLoadContextResolving;
#else
AppDomain.CurrentDomain.AssemblyResolve -= refResolver.ResolveAssembly;
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build;PostBuildPublish">
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build;PostBuildPublish">

<PropertyGroup>
<PackageId>Microsoft.Orleans.OrleansCodeGenerator.Build</PackageId>
@@ -8,8 +8,8 @@

<PropertyGroup>
<TargetFramework />
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
<OutputType>Exe</OutputType>
<NoPackageAnalysis>true</NoPackageAnalysis>
<BuildOutputTargetFolder>tasks</BuildOutputTargetFolder>
@@ -12,9 +12,13 @@
</PropertyGroup>

<PropertyGroup Condition="'$(OrleansCodeGeneratorAssembly)' == ''">
<CoreAssembly>$(MSBuildThisFileDirectory)..\tasks\netcoreapp2.0\Orleans.CodeGeneration.Build.dll</CoreAssembly>
<CoreAssembly20>$(MSBuildThisFileDirectory)..\tasks\netcoreapp2.0\Orleans.CodeGeneration.Build.dll</CoreAssembly20>
<CoreAssembly21>$(MSBuildThisFileDirectory)..\tasks\netcoreapp2.1\Orleans.CodeGeneration.Build.dll</CoreAssembly21>
<FullAssembly>$(MSBuildThisFileDirectory)..\tasks\net461\Orleans.CodeGeneration.Build.exe</FullAssembly>

<CoreAssembly Condition="$(TargetFramework.Equals('netcoreapp2.0')) or $(TargetFramework.Equals('netstandard2.0'))">$(CoreAssembly20)</CoreAssembly>
<CoreAssembly Condition="$(TargetFramework.Equals('netcoreapp2.1')) or $(TargetFramework.Equals('netstandard2.1'))">$(CoreAssembly21)</CoreAssembly>

<!-- Specify the assembly containing the MSBuild tasks. -->
<MSBuildIsCore Condition="'$(MSBuildRuntimeType)' == 'Core' or '$(OS)' != 'Windows_NT'">true</MSBuildIsCore>
<TaskAssembly Condition="'$(MSBuildIsCore)' == 'true'">$(CoreAssembly)</TaskAssembly>
@@ -4,6 +4,11 @@
<RootNamespace>TestFSharp</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

This comment has been minimized.

Copy link
@sergeybykov

sergeybykov Jun 13, 2018

Member

We probably don't need this because there's already the change in Directory.Build.props.

<NoWarn>;1591;1591;2003</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<Compile Include="Types.fs" />
@@ -4,6 +4,12 @@
<RootNamespace>TestFSharpInterfaces</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

This comment has been minimized.

Copy link
@sergeybykov

sergeybykov Jun 13, 2018

Member

We probably don't need this because there's already the change in Directory.Build.props.

<NoWarn>;1591;1591;2003</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>;1591;1591;2003</NoWarn>
</PropertyGroup>

<ItemGroup>
<Compile Include="IFSharpBaseInterface.fs" />
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.