-
Notifications
You must be signed in to change notification settings - Fork 635
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
Conversation
Co-Authored-By: pinzart <[email protected]>
Co-Authored-By: pinzart <[email protected]>
Co-Authored-By: pinzart <[email protected]>
Co-Authored-By: pinzart <[email protected]>
using System.Security.AccessControl; | ||
using System.Security.Principal; | ||
using System.Xml; | ||
using Newtonsoft.Json; | ||
|
||
namespace DynamoUtilities | ||
{ | ||
internal static class OSHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of an unexpected location I guess - inside path helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed overkill to create a new .cs file for just a couple lines of code
<None Include="FFI\FFICppFunction.cs" /> | ||
<None Include="FFI\PInvokeFFI.cs" /> | ||
<Compile Condition=" '$(TargetFramework)' == 'net6.0' " Remove="FFI\FFICppFunction.cs" /> | ||
<Compile Condition=" '$(TargetFramework)' == 'net6.0' " Remove="FFI\PInvokeFFI.cs" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these files actually still used, even in net framework 48?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THey are not compiled. Not sure if they are still around for other reasons (like to revisit the functionality)
@@ -20,14 +20,18 @@ | |||
<ItemGroup> | |||
<None Remove="CoreNodeModelsImages.resources" /> | |||
</ItemGroup> | |||
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' "> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just dump this node - I don't think theres anything it can do that a code block cannot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to minimize the chages to our net48 build..so we do not have any surprises
Maybe we can do this as a separate task
<Reference Include="Microsoft.CSharp" /> | ||
<PackageReference Include="DynamoVisualProgramming.LibG_229_0_0" Version="2.16.0.3357"/> | ||
<PackageReference Include="ncalc" Version="1.3.8"> | ||
<!--Exclude copying the runtime dlls because we need to keep binary compatibility with Revit for now --> | ||
<ExcludeAssets>runtime</ExcludeAssets> | ||
</PackageReference> | ||
<Reference Include="PresentationCore" /> | ||
</ItemGroup> | ||
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' "> | ||
<PackageReference Include="CoreCLR-NCalc" Version="2.2.92" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, I don't think it's worth the complexity. Maybe we can even migrate to a codeblock or python.
@@ -52,7 +52,9 @@ public class Preloader | |||
/// typical setup this would be the same directory that contains Dynamo | |||
/// core modules. This must represent a valid directory. | |||
/// </param> | |||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so how will ASM be loaded on linux builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still WIP
My current thoughts were to only support it via command line argument
<TargetFramework>net6.0</TargetFramework> | ||
<!--Needed to copy nuget package assemblies to output folder. Anet6 issue--> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<GenerateDependencyFile>false</GenerateDependencyFile> |
There was a problem hiding this comment.
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)
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 |
There was a problem hiding this comment.
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
on: [push,pull_request] | ||
jobs: | ||
build: | ||
runs-on: windows-latest |
There was a problem hiding this comment.
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
</GetReferenceAssemblyPaths> | ||
<PropertyGroup> | ||
<SystemDrawingDllPath Condition=" '$(TargetFramework)' == 'net48' ">$(FrameworkAssembliesPath)System.Drawing.dll</SystemDrawingDllPath> | ||
<!--Requires a reference to "System.Drawing.Common" Version="7.0.0" --> |
There was a problem hiding this comment.
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 ...)
@@ -52,7 +52,9 @@ public class Preloader | |||
/// typical setup this would be the same directory that contains Dynamo | |||
/// core modules. This must represent a valid directory. | |||
/// </param> | |||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still WIP
My current thoughts were to only support it via command line argument
@@ -20,14 +20,18 @@ | |||
<ItemGroup> | |||
<None Remove="CoreNodeModelsImages.resources" /> | |||
</ItemGroup> | |||
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' "> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to minimize the chages to our net48 build..so we do not have any surprises
Maybe we can do this as a separate task
using Microsoft.Win32; | ||
using NDesk.Options; | ||
|
||
namespace Dynamo.Applications | ||
{ | ||
#if NET6_0_OR_GREATER | ||
// Add the same signature for the OptionSet.Add method as found in the NDesk.Options package for net48 | ||
internal static class OptionsExtensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be done if we decide it is better to keep the packages to a minimum but with more if def code
using Microsoft.Win32; | ||
using NDesk.Options; | ||
|
||
namespace Dynamo.Applications | ||
{ | ||
#if NET6_0_OR_GREATER | ||
// Add the same signature for the OptionSet.Add method as found in the NDesk.Options package for net48 | ||
internal static class OptionsExtensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that whatever package we choose, will be part of our releases.
I do not think the NodeDocumentationMarkdownGenerator and its references are part of the release
@@ -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' "> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is built in
using Microsoft.Win32; | ||
using NDesk.Options; | ||
|
||
namespace Dynamo.Applications | ||
{ | ||
#if NET6_0_OR_GREATER | ||
// Add the same signature for the OptionSet.Add method as found in the NDesk.Options package for net48 | ||
internal static class OptionsExtensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it strictly necessary to keep combability here? I think we can get close enough. Maybe something we do for 3.0.
<ItemGroup> | ||
<PackageReference Include="AvalonEdit" Version="4.3.1.9430" CopyXML="true" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
<ItemGroup Label="Common Depenedencies"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling
public string CERLocation { get; set; } = String.Empty; | ||
} | ||
#endif | ||
|
There was a problem hiding this comment.
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.
#if NET6_0_OR_GREATER | ||
internal class CMDLineOptions | ||
{ | ||
[Option('l', "Locale", Required = false, HelpText = "Running Dynamo under a different locale setting.")] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @mjkkirschner @sm6srw
There was a problem hiding this comment.
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.
<PropertyGroup Condition="$(Platform.Contains('NET60'))" > | ||
<TargetFramework>net6.0</TargetFramework> | ||
<!--Needed to copy nuget package assemblies to output folder. Anet6 issue--> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
```
[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.")] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compile was fine
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -378,7 +465,7 @@ private static bool PreloadASM(string asmPath, out string geometryFactoryPath, o | |||
CLIMode = CLImode | |||
}; | |||
config.AuthProvider = CLImode ? null : new Core.IDSDKManager(); | |||
config.UpdateManager = CLImode ? null : InitializeUpdateManager(); | |||
config.UpdateManager = CLImode ? null : OSHelper.IsWindows() ? InitializeUpdateManager() : null; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
@@ -8,11 +8,12 @@ | |||
<AppDesignerFolder>Properties</AppDesignerFolder> | |||
<RootNamespace>DynamoCLI</RootNamespace> | |||
<AssemblyName>DynamoCLI</AssemblyName> | |||
<SelfContained>false</SelfContained> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@@ -69,6 +69,7 @@ | |||
<None Remove="Views\GuidedTour\HtmlPages\Resources\ConnectTheNode.gif" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="AvalonEdit" Version="4.3.1.9430" CopyXML="true"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this packageRefecence was moved from DynamoUtilities. DynamoCoreWpf.csproj is the project that actually uses it.
I think it was used by DynamoUtilities only for an indirect reference to System.Collections.Immutable
.
I refactored it so that we do not need it in DynamoUtilities.
This might cause compile issues...if someone was using AvalonEdit
APIs by referencing the DynamoUtilities project ...But from what I was able to check...looks like we are ok with the autodesk integrators.
@@ -9,7 +9,7 @@ | |||
<RootNamespace>DynamoPackages</RootNamespace> | |||
<AssemblyName>DynamoPackages</AssemblyName> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' "> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, will net6 builds be able to load config files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes...there is a separate ConfigurationManager nuget package for that
return Finfo.IsReadOnly || !HasWritePermissionOnDir(Finfo.Directory.ToString()); | ||
|
||
// We have no cross platform Directory access writes APIs. | ||
bool hasWritePermissionOnDir = OSHelper.IsWindows() ? HasWritePermissionOnDir(Finfo.Directory.ToString()) : true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess now wherever this is used should be wrapped in try catch?
Maybe update summary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure yet how we should go about it for linux. There are packages that have similar APIs ...(as far as I remember)
Or we can implement a simple version ourselves.
I think we need to do this in a separate task...talk about acceptance criteria and maybe some spikes too
@@ -611,11 +622,28 @@ internal static bool IsASMInstallationComplete(IEnumerable<string> filePaths, in | |||
/// <returns></returns> | |||
/// <param name="searchPattern">optional - to be used for testing - default is the ASM search pattern</param> | |||
/// <returns></returns> | |||
public static Version GetVersionFromPath(string asmPath, string searchPattern = "ASMAHL*.dll") | |||
public static Version GetVersionFromPath(string asmPath, string searchPattern = "*ASMAHL*.*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asm binaries for linux do not have a .dll extension (linux has .so - shared objects)
I changed it so that we do not need the extension
#if NET6_0_OR_GREATER | ||
if (!OperatingSystem.IsWindows()) | ||
{ | ||
string fileName = Path.GetFileNameWithoutExtension(ASMFilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, cool, but ugh - I'm surprised theres nothing cross platform here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.so (shared objects) do not have the same metadata as dlls.
I think the recommended versioning technique is to bake the version in the name as a prefix (ex libtsplines.so.10)
A lot of changes, and still some questions, but it looks good. |
Purpose:
Provide a local configuration/system to build DynamoCore for net60 (windows and linux)
What changed:
Added local build configuration for dotnet6.0 (linux and windows supported OSs)
A new solution DynamoCore.net6.sln has been added, to make DEV experience easier. When the dotnet6 ecosystem is mature enough, we can move everything over into a single Dynamo.Core.sln (multi target without UI) and a Dynamo.All.sln (multi target with UI)
Windows specific APIs have been marked with a
[SupportedOSPlatform("Windows")]
attribute.net48 and net6.0 Packages have been segregated.
Some of the codebase has changed to accommodate net6.0 and non-windows APIs
TODO:
The new PackageReferences (for dotnet6.0) have not been vetted properly.
Bring in more of the Dynamo Core projects.
Remove windows only dependencies from the Core and Linux build if not needed (ex image resources). Having certain resources means we are stuck with msbuild and cannot simply use dotnet build for our build process
There are dependencies of DynamoCore+Linux which still need to be compiled specifically for linux (Ex. LibG native binaries need to be compiled for Linux or else they will not load properly)
DynamoCore.net6.sln
: