Skip to content

Commit

Permalink
Cross platform DynamoCore local setup (part1) (#13547)
Browse files Browse the repository at this point in the history
* Local config for dotnet6 target framework

Co-authored-by: pinzart <[email protected]>
  • Loading branch information
pinzart90 and pinzart authored Dec 16, 2022
1 parent 47ddfa0 commit 53e2800
Show file tree
Hide file tree
Showing 37 changed files with 750 additions and 132 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/dynamoNet6.0_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build Dynamo using latest VS and DotNET
name: Dynamo-net6.0-Build
on: [push,pull_request]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout Dynamo Repo
uses: actions/checkout@v2
with:
path: Dynamo
repository: DynamoDS/Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Install dependencies for windows runtime
run: dotnet restore $Env:GITHUB_WORKSPACE\Dynamo\src\DynamoCore.net6.sln --runtime=win10-x64
- name: Build Dynamo with MSBuild for Windows
run: |
echo "***Continue with the build, Good luck developer!***"
cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\"
.\MSBuild.exe $Env:GITHUB_WORKSPACE\Dynamo\src\DynamoCore.net6.sln /p:Configuration=Release /p:Platform=NET60_Windows
# look for Dynamo
- name: Navigate to Dynamo Windows Folder
run: |
cd "$Env:GITHUB_WORKSPACE\Dynamo\bin\NET60_Windows\Release"
echo "***Locating DynamoCLI for Windows!***"
test ".\DynamoCLI.exe" && echo "DynamoCLI exists!"
- name: Install dependencies for linux runtime
run: dotnet restore $Env:GITHUB_WORKSPACE\Dynamo\src\DynamoCore.net6.sln --runtime=linux-x64
- name: Build Dynamo with MSBuild for Linux
run: |
echo "***Continue with the build, Good luck developer!***"
cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\"
.\MSBuild.exe $Env:GITHUB_WORKSPACE\Dynamo\src\DynamoCore.net6.sln /p:Configuration=Release /p:Platform=NET60_Linux
- name: Navigate to Dynamo Linux Folder
run: |
cd "$Env:GITHUB_WORKSPACE\Dynamo\bin\NET60_Linux\Release"
echo "***Locating DynamoCLI for Linux!***"
test ".\DynamoCLI.exe" && echo "DynamoCLI exists!"
43 changes: 38 additions & 5 deletions src/Config/CS_SDK.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project>
<PropertyGroup>
<Platforms>AnyCPU;x64;NET60_Windows;NET60_Linux;</Platforms>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<PlatformTarget >x64</PlatformTarget>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
<TargetFramework>net48</TargetFramework>
<FileAlignment>512</FileAlignment>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<OutputPath Condition=" '$(OutputPath)' == '' ">$(SolutionDir)..\bin\AnyCPU\$(Configuration)</OutputPath>
<BaseIntermediateOutputPath>int\</BaseIntermediateOutputPath>
<OutputPath Condition=" '$(OutputPath)' == '' ">$(SolutionDir)..\bin\$(Platform)\$(Configuration)</OutputPath>
<NunitPath Condition=" '$(NunitPath)' == '' ">$(SolutionDir)..\extern\NUnit</NunitPath>
<SharpDXDirectXVersion>DirectX11</SharpDXDirectXVersion>
<ErrorReport>prompt</ErrorReport>
Expand All @@ -19,8 +20,6 @@
<TestProjectDefaults Condition="$(MSBuildProjectDirectory.Contains('test'))">true</TestProjectDefaults>
<TestProjectDefaults Condition=" '$(TestProjectDefaults)' == '' ">false</TestProjectDefaults>
<NoWarn>MSB3539</NoWarn><!--The value of the property "BaseIntermediateOutputPath" was modified after it was used by MSBuild-->
<!--This is used to set the framework version for icon resource dll generation (lookup of system.drawing.dll)-->
<ResourceGeneration_FrameworkVersion>v4.8</ResourceGeneration_FrameworkVersion>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
Expand All @@ -34,18 +33,37 @@
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Platform.Contains('NET60'))" >
<TargetFramework>net6.0</TargetFramework>
<!--Needed to copy nuget package assemblies to output folder. Anet6 issue-->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<GenerateDependencyFile>false</GenerateDependencyFile>
</PropertyGroup>
<PropertyGroup Condition="$(Platform.Contains('Windows'))" >
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="$(Platform.Contains('Linux'))" >
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup>
<BaseIntermediateOutputPath>int\$(TargetFramework)\</BaseIntermediateOutputPath>
<IntermediateOutputPath>obj\$(TargetFramework)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Remove="obj\**" />
<EmbeddedResource Remove="obj\**" />
<None Remove="obj\**" />
<None Remove="*.resources" />
<Compile Remove="int\**" />
<EmbeddedResource Remove="int\**" />
<None Remove="int\**" />
</ItemGroup>
<ItemGroup>
<Compile Condition="'$(ProjectName)'!='AssemblyInfoGenerator'" Include="$(SolutionDir)AssemblySharedInfoGenerator\AssemblySharedInfo.cs">
<Link>Properties\AssemblySharedInfo.cs</Link>
</Compile>
</ItemGroup>
<ItemDefinitionGroup>
<ItemDefinitionGroup Condition=" '$(TargetFramework)' == 'net48' ">
<ProjectReference>
<Private>false</Private>
</ProjectReference>
Expand Down Expand Up @@ -91,4 +109,19 @@
<Copy SourceFiles="@(PDBContent)" DestinationFolder="$(OutDir)$(PackagesOutputSubdirectory)" Condition="Exists('%(FullPath)')" />
<Copy SourceFiles="@(DLLContent)" DestinationFolder="$(OutDir)$(PackagesOutputSubdirectory)$(Local_CopyToSubdirectory)" Condition="Exists('%(FullPath)')" />
</Target>
<Target Name="ResolveSateliteResDeps" AfterTargets="Build" Condition=" '$(OS)' != 'Unix' ">
<!-- Get System.Drawing.dll -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'net48' ">
<!--This is used to set the framework version for icon resource dll generation (lookup of system.drawing.dll)-->
<ResourceGeneration_FrameworkVersion>v4.8</ResourceGeneration_FrameworkVersion>
</PropertyGroup>
<GetReferenceAssemblyPaths Condition=" '$(TargetFramework)' == 'net48' " TargetFrameworkMoniker=".NETFramework, Version=$(ResourceGeneration_FrameworkVersion)">
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="FrameworkAssembliesPath" />
</GetReferenceAssemblyPaths>
<PropertyGroup>
<SystemDrawingDllPath Condition=" '$(TargetFramework)' == 'net48' ">$(FrameworkAssembliesPath)System.Drawing.dll</SystemDrawingDllPath>
<!--Requires a reference to "System.Drawing.Common" Version="7.0.0" -->
<SystemDrawingDllPath Condition=" '$(TargetFramework)' == 'net60' ">$(PkgSystem_Drawing_Common)\lib\net6.0\System.Drawing.Common.dll</SystemDrawingDllPath>
</PropertyGroup>
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/Dynamo.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1013,4 +1013,4 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {89CB19C6-BF0A-4E6A-BFDA-79D143EAB59D}
EndGlobalSection
EndGlobal
EndGlobal
9 changes: 6 additions & 3 deletions src/DynamoApplications/DynamoApplications.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
Expand All @@ -9,8 +9,11 @@
<RootNamespace>DynamoApplications</RootNamespace>
<AssemblyName>DynamoApplications</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NDesk.Options" Version="0.2.1" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="CommandLineParser" Version="2.8.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<PackageReference Include="NDesk.Options" Version="0.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DynamoCore\DynamoCore.csproj">
Expand Down
97 changes: 92 additions & 5 deletions src/DynamoApplications/StartupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,70 @@
using Dynamo.Updates;
using DynamoApplications.Properties;
using DynamoShapeManager;
using DynamoUtilities;
using Microsoft.Win32;
#if NET6_0_OR_GREATER
using CommandLine;
#else
using NDesk.Options;
#endif

namespace Dynamo.Applications
{
#if NET6_0_OR_GREATER
internal class CMDLineOptions
{
[Option('l', "Locale", Required = false, HelpText = "Running Dynamo under a different locale setting.")]
public string Locale { get; set; } = String.Empty;
[Option('c', "CommandFilePath", Required = false, HelpText = "Instruct Dynamo to open a commandfile and run the commands it contains at this path," +
"this option is only supported when run from DynamoSandbox")]
public string CommandFilePath { get; set; } = String.Empty;
[Option('o', "OpenFilePath", Required = false, HelpText = "Instruct Dynamo to open headless and run a dyn file at this path.")]
public string OpenFilePath { get; set; } = String.Empty;
[Option('v', "Verbose", Required = false, HelpText = "Instruct Dynamo to output all evalautions it performs to an xml file at this path.")]
public string Verbose { get; set; } = String.Empty;
[Option('x', "ConvertFile", Required = false, HelpText = "When used in combination with the 'O' flag, opens a .dyn file from the specified path and converts it to .json." +
"File will have the .json extension and be located in the same directory as the original file.")]
public bool ConvertFile { get; set; }
[Option('g', "Geometry", Required = false, HelpText = "Instruct Dynamo to output geometry from all evaluations to a json file at this path.")]
public string GeometryFilePath { get; set; } = String.Empty;
[Option('i', "Import", Required = false, HelpText = "Instruct Dynamo to import an assembly as a node library.This argument should be a filepath to a single.dll" +
" - if you wish to import multiple dlls - list the dlls separated by a space: -i 'assembly1.dll' 'assembly2.dll'")]
public IEnumerable<String> ImportedPaths { get; set; } = new List<string>();
[Option('g', "GeometryPath", Required = false, HelpText = "relative or absolute path to a directory containing ASM. When supplied, instead of searching the hard disk for ASM, it will be loaded directly from this path.")]
public string ASMPath { get; set; } = String.Empty;
[Option('k', "KeepAlive", Required = false, HelpText = "Keepalive mode, leave the Dynamo process running until a loaded extension shuts it down.")]
public bool KeepAlive { get; set; }
[Option('n', "NoConsole", Required = false, HelpText = "Don't rely on the console window to interact with CLI in Keepalive mode.")]
public bool NoConsole { get; set; }
[Option('u', "UserData", Required = false, HelpText = "Specify user data folder to be used by PathResolver with CLI.")]
public string UserDataFolder { get; set; } = String.Empty;
[Option("CommonData", Required = false, HelpText = "Specify common data folder to be used by PathResolver with CLI.")]
public string CommonDataFolder { get; set; } = String.Empty;
[Option("HostName", Required = false, HelpText = "Identify Dynamo variation associated with host.")]
public string HostName { get; set; } = String.Empty;
[Option("DisableAnalytics", Required = false, HelpText = "Disables analytics in Dynamo for the process liftime.")]
public bool DisableAnalytics { get; set; }
[Option("ParentId", Required = false, HelpText = "Identify Dynamo host analytics parent id.")]
public string ParentId { get; set; } = String.Empty;
[Option("SessionId", Required = false, HelpText = "Identify Dynamo host analytics session id.")]
public string SessionId { get; set; } = String.Empty;
[Option("CERLocation", Required = false, HelpText = "Specify the crash error report tool location on disk.")]
public string CERLocation { get; set; } = String.Empty;
}
#endif

public class StartupUtils
{
//TODO internal?
/// <summary>
/// Raised when loading of the ASM binaries fails. A failure message is passed as a parameter.
/// </summary>
public static event Action<string> ASMPreloadFailure;


#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
internal class SandboxLookUp : DynamoLookUp
{
public override IEnumerable<string> GetDynamoInstallLocations()
Expand Down Expand Up @@ -69,6 +120,34 @@ public struct CommandLineArguments
{
public static CommandLineArguments Parse(string[] args)
{
#if NET6_0_OR_GREATER

return Parser.Default.ParseArguments<CMDLineOptions>(args).MapResult((cmdArgs) => {
if (!string.IsNullOrEmpty(cmdArgs.Verbose) && string.IsNullOrEmpty(cmdArgs.OpenFilePath))
{
Console.WriteLine("you must supply a file to open if you want to save an evaluation output ");
}

return new CommandLineArguments()
{
Locale = cmdArgs.Locale,
CommandFilePath = cmdArgs.CommandFilePath,
OpenFilePath = cmdArgs.OpenFilePath,
Verbose = cmdArgs.Verbose,
ConvertFile = cmdArgs.ConvertFile,
GeometryFilePath = cmdArgs.GeometryFilePath,
ImportedPaths = cmdArgs.ImportedPaths,
ASMPath = cmdArgs.ASMPath,
KeepAlive = cmdArgs.KeepAlive,
NoConsole = cmdArgs.NoConsole,
UserDataFolder = cmdArgs.UserDataFolder,
CommonDataFolder = cmdArgs.CommonDataFolder,
DisableAnalytics = cmdArgs.DisableAnalytics,
AnalyticsInfo = new HostAnalyticsInfo() { HostName = cmdArgs.HostName, ParentId = cmdArgs.ParentId, SessionId = cmdArgs.SessionId },
CERLocation = cmdArgs.CERLocation
};
}, errs => new CommandLineArguments());
#else
// Running Dynamo sandbox with a command file:
// DynamoSandbox.exe /c "C:\file path\file.xml"
//
Expand Down Expand Up @@ -172,14 +251,17 @@ public static CommandLineArguments Parse(string[] args)
AnalyticsInfo = new HostAnalyticsInfo() { HostName = hostname, ParentId = parentId, SessionId = sessionId },
CERLocation = cerLocation
};
#endif
}

#if NET6_0_OR_GREATER
#else
private static void ShowHelp(OptionSet opSet)
{
Console.WriteLine("options:");
opSet.WriteOptionDescriptions(Console.Out);
}

#endif
public string Locale { get; set; }
public string CommandFilePath { get; set; }
public string OpenFilePath { get; set; }
Expand All @@ -196,7 +278,6 @@ private static void ShowHelp(OptionSet opSet)
public string HostName { get; set; }
public bool DisableAnalytics { get; set; }
public HostAnalyticsInfo AnalyticsInfo { get; set; }

public string CERLocation { get; set; }
}

Expand All @@ -205,6 +286,9 @@ private static void ShowHelp(OptionSet opSet)
/// </summary>
/// <param name="geometryFactoryPath">libG ProtoInterface path</param>
/// <param name="preloaderLocation">libG folder path</param>
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
public static void PreloadShapeManager(ref string geometryFactoryPath, ref string preloaderLocation)
{
var exePath = Assembly.GetExecutingAssembly().Location;
Expand All @@ -227,6 +311,9 @@ public static void PreloadShapeManager(ref string geometryFactoryPath, ref strin
///for now, building an updatemanager instance requires finding Dynamo install location
///which if we are running on mac os or *nix will use different logic then SandboxLookup
/// </summary>
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
private static IUpdateManager InitializeUpdateManager()
{
var cfg = UpdateManagerConfiguration.GetSettings(new SandboxLookUp());
Expand Down Expand Up @@ -312,7 +399,7 @@ public static DynamoModel MakeModel(bool CLImode)

private static bool PreloadASM(string asmPath, out string geometryFactoryPath, out string preloaderLocation )
{
if (string.IsNullOrEmpty(asmPath))
if (string.IsNullOrEmpty(asmPath) && OSHelper.IsWindows())
{
geometryFactoryPath = string.Empty;
preloaderLocation = string.Empty;
Expand Down Expand Up @@ -378,7 +465,7 @@ private static DynamoModel StartDynamoWithDefaultConfig(bool CLImode,
CLIMode = CLImode
};
config.AuthProvider = CLImode ? null : new Core.IDSDKManager();
config.UpdateManager = CLImode ? null : InitializeUpdateManager();
config.UpdateManager = CLImode ? null : OSHelper.IsWindows() ? InitializeUpdateManager() : null;
config.StartInTestMode = CLImode;
config.PathResolver = CLImode ? new CLIPathResolver(preloaderLocation, userDataFolder, commonDataFolder) as IPathResolver : new SandboxPathResolver(preloaderLocation) as IPathResolver;

Expand Down
6 changes: 4 additions & 2 deletions src/DynamoCLI/DynamoCLI.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
Expand All @@ -8,11 +8,12 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DynamoCLI</RootNamespace>
<AssemblyName>DynamoCLI</AssemblyName>
<SelfContained>false</SelfContained>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="Microsoft.CSharp" />
<Reference Include="WindowsBase" />
</ItemGroup>
Expand Down Expand Up @@ -40,6 +41,7 @@
<ProjectReference Include="..\Libraries\DesignScriptBuiltin\DesignScriptBuiltin.csproj">
<Project>{c0d6dee5-5532-4345-9c66-4c00d7fdb8be}</Project>
<Name>DesignScriptBuiltin</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\NodeServices\DynamoServices.csproj">
<Project>{ef879a10-041d-4c68-83e7-3192685f1bae}</Project>
Expand Down
5 changes: 2 additions & 3 deletions src/DynamoCLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using Dynamo.Applications;
using Dynamo.Models;
Expand Down Expand Up @@ -30,7 +32,6 @@ static internal void Main(string[] args)
var thread = new Thread(() => RunKeepAlive(cmdLineArgs));

thread.Name = "DynamoModelKeepAlive";
thread.SetApartmentState(ApartmentState.STA);
thread.Start();

if (!useConsole)
Expand Down Expand Up @@ -85,8 +86,6 @@ private static void RunKeepAlive(StartupUtils.CommandLineArguments cmdLineArgs)
Console.WriteLine("DynamoCLI is running in keepalive mode");
Console.WriteLine("Press Enter to shutdown...");
}

System.Windows.Threading.Dispatcher.Run();
}
catch
{
Expand Down
Loading

0 comments on commit 53e2800

Please sign in to comment.