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

Cross platform DynamoCore local setup (part1) #13547

Merged
merged 41 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9cb07b6
update
pinzart Nov 18, 2022
59023a2
update
pinzart Nov 18, 2022
4776219
update
pinzart Nov 18, 2022
ee7512c
update
pinzart Nov 18, 2022
d4d5635
update
pinzart Nov 18, 2022
776c3b4
update
pinzart Nov 18, 2022
444136a
Update DynamoCLI.csproj
pinzart Nov 21, 2022
2335036
update
pinzart Nov 21, 2022
918753d
Merge branch 'master' into stuff
pinzart90 Nov 21, 2022
2c6c5d9
update
pinzart Nov 21, 2022
3c527a7
Update PathHelper.cs
pinzart Nov 21, 2022
d7870c6
update
pinzart Nov 21, 2022
6b8eeee
update
pinzart Nov 21, 2022
8fd0322
Update Program.cs
pinzart Nov 21, 2022
a9e1787
Update Program.cs
pinzart Nov 21, 2022
93a802c
update
pinzart Nov 21, 2022
b515670
update
pinzart Nov 30, 2022
0f91091
Update PathHelper.cs
pinzart Dec 2, 2022
d8685f1
update
pinzart Dec 3, 2022
4af3fad
update
pinzart Dec 5, 2022
efffd0f
update
pinzart Dec 5, 2022
d91f5fd
Merge branch 'master' into stuff
pinzart90 Dec 6, 2022
71c948a
Merge branch 'master' into stuff
pinzart Dec 6, 2022
edaef93
Merge branch 'stuff' of https://github.com/DynamoDS/Dynamo into stuff
pinzart Dec 7, 2022
087615a
update
pinzart Dec 7, 2022
64167db
Merge branch 'master' into stuff
pinzart90 Dec 7, 2022
3b1f24c
Update DynamoCLI.csproj
pinzart Dec 7, 2022
631f2bc
Merge branch 'stuff' of https://github.com/DynamoDS/Dynamo into stuff
pinzart Dec 7, 2022
e9b53de
Merge branch 'master' into stuff
pinzart Dec 8, 2022
2cf6044
update
pinzart Dec 8, 2022
0820844
Update DynamoCoreWpf.csproj
pinzart Dec 8, 2022
2f85822
Update CS_SDK.props
pinzart Dec 8, 2022
ead7eec
Update CS_SDK.props
pinzart Dec 8, 2022
d4cebb0
Update CS_SDK.props
pinzart Dec 8, 2022
26a7566
Create dynamoNet6.0_build.yml
pinzart Dec 8, 2022
a7d8b6d
Update dynamoNet6.0_build.yml
pinzart Dec 8, 2022
6c6bb7b
Update dynamoNet6.0_build.yml
pinzart Dec 8, 2022
6e8b297
Update dynamoNet6.0_build.yml
pinzart Dec 8, 2022
6cc218f
Update dynamoNet6.0_build.yml
pinzart Dec 8, 2022
30445f6
switch to cmdlin
pinzart Dec 13, 2022
66229a4
update
pinzart Dec 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@mjkkirschner mjkkirschner Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also build on Ubuntu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need msbuild for now. Not sure if msbuild is available on liinux machines

Copy link
Member

@mjkkirschner mjkkirschner Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well you can do mono msbuild...
Why do we need msbuild?

I guess it's not super important because msbuild supports cross compiling - is that correct?... kind of a pain to maintain a windows build machine though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need a windows build machine to build Dynamo.net6.All (with UI)
DynamoCore (no UI) should be able to build on linux and run on any machine.

I guess if we need a windows machine for all of dynamo (with ui) anyway, then we can just build every part of it there

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using dotnet restore because it allows us to specify the target runtime (windows or linux)
nuget does not have this option.
This is an issue because we are using a common properties file (CS_SDK.props) with the default configs set for DynamoAll and not DynamoCore builds.
This can be remediated in other ways....but I think it is good enough for now

- 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\"
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
.\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>
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved
<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>
Copy link
Member

@mjkkirschner mjkkirschner Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so... does this turn all nuget references into copy local true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it copies all referenced assemblies in the output path

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds dangerous - do we have duplicate copies now of things like newtonsoft.json in the /nodes and /bin folders?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate copies will not happen because all projects that have the outputPath to /nodes also have a redirect attribute

    <ReferenceCopyLocalPaths>
	  <!--Copy all assembly references to the OutputPath parent dir (/nodes/../) -->
	  <DestinationSubDirectory>..\</DestinationSubDirectory>
    </ReferenceCopyLocalPaths>
    ```

<GenerateDependencyFile>false</GenerateDependencyFile>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I turned this off because it is causing issues (could not find assembly references in the app directory) with the existing Copy local=false settings in Dynamo. We do not need the deps files at the moment

.deps.json - A list of dependencies, as well as compilation context data and compilation dependencies. 
Not technically required, but required to use the servicing or package cache/shared package install features. 
It can be used to configure dynamic linking to assemblies that come from packages. 
As mentioned above, .NET Core can be configured to dynamically load assemblies from multiple locations. These locations include:

App base directory (in the same folder as the entry point application, no config required)
Package cache folders (NuGet restore cache or NuGet fallback folders)
An optimized package cache or runtime packages store
The servicing index (rarely used. For Windows Update purposes.)
Shared framework (configured via runtimeconfig.json)

</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' ">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is $(OS) defined? Built in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is built in

<!-- 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" -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is marked in our wiki as a TODO.
Currently it looks like the APIs we are using are ok for windows and linux.
In the future, we can either switch to a new crossplatform package or stop generating icons/resources for dynamo core builds (linux and/or windows ...)

<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.")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of the new cmdline args have changed (as oposed to the old way - using NDesk.Options)
The new CommandLineParser package only supports 2 names (short - single char and long any string). Some arguments will not have a short name because of collisions issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@mjkkirschner mjkkirschner Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, bummer, I regret the suggestion - 😢 - but thanks for making the change, probably good to switch to something that actually gets updated.

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.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, so what happens here with the two g flags? Does this throw an error at compile time or just ignore the matching flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not even try. Obviously something is not going to work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile was fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be resolved here but we should probably align these and just document the break between the two targets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add a task for it once we are sure that this is the package we want

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to use a separate internal class for the CommandLine options. Hopefully this is less cluttered and more readable.

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")]
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
#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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is windows only about updatemanager?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SandboxLookUp is the one. Used inside the InitializeUpdateManager
I did not try to make it work for linux yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully we can get rid of most of the Windows only APIs from DynamoCore
This can be done in steps

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious - what happens if this is true, the exe also includes all the binaries in the bin folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SelfContained = true will copy all the dotnet6 runtime dlls

</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