Skip to content

Commit

Permalink
DYN-7391: As a Dynamo dev, I want to update ASM component support for…
Browse files Browse the repository at this point in the history
… Global Launch (#15506)
  • Loading branch information
sm6srw authored Oct 3, 2024
1 parent f2b39ba commit ef9bacc
Show file tree
Hide file tree
Showing 24 changed files with 365 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/Config/CS_SDK.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<!--Use the property DotNet to set TargetFramework from commandline without forcing it on all projects-->
<!--Ex. DynamoServices uses TargetFramework netstandard2.0 -->
<DotNet>net8.0</DotNet>
<!--Use LibGVer to tell the CI/CD pipeline what the prefered LIBG version is for testing-->
<LIBGVer>libg_231_0_0</LIBGVer>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
<TargetFramework>$(DotNet)</TargetFramework>
<FileAlignment>512</FileAlignment>
Expand Down
1 change: 1 addition & 0 deletions src/DynamoApplications/StartupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public static void PreloadShapeManager(ref string geometryFactoryPath, ref strin

var versions = new[]
{
new Version(231,0,0),
new Version(230,0,0),
};

Expand Down
17 changes: 10 additions & 7 deletions src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<PackageReference Include="Autodesk.IDSDK" Version="1.1.8" />
<PackageReference Include="Greg" Version="3.0.2.6284" />
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" GeneratePathProperty="true" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734" GeneratePathProperty="true" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" CopyXML="true" />
<PackageReference Include="RestSharp" Version="112.0.0" CopyXML="true" />
<PackageReference Include="Lucene.Net" Version="4.8.0-beta00016" />
Expand Down Expand Up @@ -112,15 +113,16 @@

<Target Name="BeforeBuildOps" BeforeTargets="Build">
<PropertyGroup>
<LibGProtoGeometryLibGLocale>$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\libg_locale</LibGProtoGeometryLibGLocale>
<LibGProtoGeometryLibGLocale>$(PkgDynamoVisualProgramming_LibG_231_0_0)\tools\libg_locale</LibGProtoGeometryLibGLocale>
</PropertyGroup>
<ItemGroup>
<LibGInterface Include="$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\netstandard2.0\$(LibGOsToken)\LibG.Interface.dll" />
<LibGProtoGeometryDLL Include="$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\netstandard2.0\$(LibGOsToken)\ProtoGeometry.dll" />
<LibGProtoGeometryXML Include="$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\netstandard2.0\$(LibGOsToken)\ProtoGeometry.XML" />
<LibG230Deps Include="$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\netstandard2.0\$(LibGOsToken)\asm_deps.csproj" />
<LibGProtoGeometryUICulture Include="$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\netstandard2.0\$(LibGOsToken)\$(UICulture)\*" />
<LibGInterface Include="$(PkgDynamoVisualProgramming_LibG_231_0_0)\tools\netstandard2.0\$(LibGOsToken)\LibG.Interface.dll" />
<LibGProtoGeometryDLL Include="$(PkgDynamoVisualProgramming_LibG_231_0_0)\tools\netstandard2.0\$(LibGOsToken)\ProtoGeometry.dll" />
<LibGProtoGeometryXML Include="$(PkgDynamoVisualProgramming_LibG_231_0_0)\tools\netstandard2.0\$(LibGOsToken)\ProtoGeometry.XML" />
<LibG231Deps Include="$(PkgDynamoVisualProgramming_LibG_231_0_0)\tools\netstandard2.0\$(LibGOsToken)\asm_deps.csproj" />
<LibGProtoGeometryUICulture Include="$(PkgDynamoVisualProgramming_LibG_231_0_0)\tools\netstandard2.0\$(LibGOsToken)\$(UICulture)\*" />
<LibG230 Include="$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\netstandard2.0\$(LibGOsToken)\LibG_230_0_0\*" />
<LibG231 Include="$(PkgDynamoVisualProgramming_LibG_231_0_0)\tools\netstandard2.0\$(LibGOsToken)\LibG_231_0_0\*" />
<SampleFiles Include="$(SolutionDir)..\doc\distrib\Samples\**\*.*" />
<NodeHelpMDFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.md" />
<NodeHelpDYNFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.dyn" />
Expand Down Expand Up @@ -152,9 +154,10 @@
<Copy SourceFiles="@(LibGProtoGeometryXml)" DestinationFolder="$(OutputPath)" />
<Copy SourceFiles="@(LibGProtoGeometryXml)" DestinationFolder="$(OutputPath)\$(UICulture)" />
<Copy SourceFiles="@(LibGProtoGeometryUICulture)" DestinationFolder="$(OutputPath)\$(UICulture)" />
<Copy Condition="$(Platform.Contains('Linux'))" SourceFiles="@(LibG230Deps)" DestinationFolder="$(OutputPath)libg_230_0_0\asm_deps\" />
<Copy SourceFiles="@(LibG231Deps)" DestinationFolder="$(OutputPath)libg_231_0_0\asm_deps\" />
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command Copy-Item -Path $(LibGProtoGeometryLibGLocale) -Destination $(OutputPath) -Recurse -Force" />
<Copy SourceFiles="@(LibG230)" DestinationFolder="$(OutputPath)libg_230_0_0\" />
<Copy SourceFiles="@(LibG231)" DestinationFolder="$(OutputPath)libg_231_0_0\" />
<Copy SourceFiles="@(SampleFiles)" DestinationFolder="$(OutputPath)samples\%(RecursiveDir)" />
<Copy SourceFiles="@(LocalizedResources)" DestinationFolder="$(OutputPath)%(RecursiveDir)" />
<Copy SourceFiles="$(ProjectDir)\BuiltInAndOperators\Operators.xml" DestinationFolder="$(OutputPath)\$(UICulture)" />
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/DynamoCoreWpf.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">
<PropertyGroup>
<UILib>true</UILib>
</PropertyGroup>
Expand Down Expand Up @@ -186,7 +186,7 @@
<PackageReference Include="HelixToolkit.Core.Wpf" Version="2.24.0" />
<PackageReference Include="HelixToolkit.SharpDX.Core.Wpf" Version="2.24.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734"/>
<PackageReference Include="FontAwesome5" Version="2.1.11" />
<PackageReference Include="AvalonEdit" Version="6.3.0.90" CopyXML="true" />
<PackageReference Include="Greg" Version="3.0.2.6284" />
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoManipulation/DynamoManipulation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Analysis/Analysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<None Remove="AnalysisImages.resources" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734"/>
<ProjectReference Include="..\..\DynamoCore\DynamoCore.csproj">
<Project>{7858fa8c-475f-4b8e-b468-1f8200778cf8}</Project>
<Name>DynamoCore</Name>
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/CoreNodes/CoreNodes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Compile Remove="GeometryColor.cs" />
</ItemGroup>
<ItemGroup Label="Common dependencies">
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DynamoCore\DynamoCore.csproj">
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/GeometryColor/GeometryColor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NoWarn>MSB3539;CS1591;NUnit2005;NUnit2007;CS0618;CS0612;CS0672</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DynamoCore\DynamoCore.csproj">
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/GeometryUI/GeometryUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ReferenceCopyLocalPaths>
</ItemDefinitionGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/GeometryUIWpf/GeometryUIWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ReferenceCopyLocalPaths>
</ItemDefinitionGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734"/>
</ItemGroup>
<ItemGroup>
<Page Include="Controls\ExportWithUnitsControl.xaml">
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Tesellation/Tessellation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NoWarn>MSB3539;CS1591;NUnit2005;NUnit2007;CS0618;CS0612;CS0672</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6246" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.2734"/>
<PackageReference Include="MIConvexHull" version="1.1.17.411" CopyPDB="true" />
<PackageReference Include="StarMath" version="2.0.17.1019" CopyPDB="true" />
<PackageReference Include="System.Resources.Extensions" Version="5.0.0" />
Expand Down
182 changes: 182 additions & 0 deletions src/Tools/DynamoInstallDetective/AscSDKWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
using System;
using System.IO;
using Microsoft.Win32;

namespace DynamoInstallDetective
{
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
///
/// Autodesk Shared Components SDK
///
/// There is one or more installed shared components packages for each major version.
/// Major versions are for example 2026, 2027 and 2028 and corresponds to our global launches.
/// Minor versions are for example 1.0.0, 1.1.0, 2.0.0 etc.
///
/// These packages are ususally installed in "C:\Program Files\Common Files\Autodesk Shared\Components",
/// for example in C:\Program Files\Common Files\Autodesk Shared\Components\2026\1.0.0 for version 1.0.0 of the package used by 2026 products.
///
/// There is no guarantee that this localtion is used as it can be overridden at deplyments time. Instead, the registry should be queried
/// for the final location.
///
/// The registry location "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\SharedComponents\" contains one key for each major version,
/// for example the key 2026 is used for the 2026 package.
///
/// Each key will hold two values:
/// Version: The current version of the package
/// InstallPath: The actual location where the package is installed.
///
/// There is usually only one minor version installed for each major version but there are situations when multiple minor versions can be installed.
/// One of these cases is when testing beta versions of the shared components. The version used can then be overridden by using an environment variable,
/// ACS_VERSION_<majorRelease> that points to the prefered version to use. So to load the 2.0-beta verion of the 2026 components you would
/// set ACS_VERSION_2026 to 2.0-beta.
///
/// All shared components are currenly installed into one flat directory for each release. Possible future changes include the ability to only install those
/// components that actually is needed. This wrapper might need to be updated at that point.
///
internal class AscSdkWrapper
{
public enum ASC_STATUS
{
SUCCESS = 0,
UNABLE_TO_SET_INSTALL_PATH = 4,
BAD_ARGS = 5,
REG_FAILED = 6,
FUNCTION_CALL_FAILED = 7,
INITIALIZE_FAILED = 8,
ODIS_SDK_INITIALIZE_FAILED = 9,
ODIS_SDK_LOCK_FAILED = 10,
ODIS_SDK_UNLOCK_FAILED = 11,
INCORRECT_REG_PATH = 12,
EMPTY_REG_VERSION = 13,
FAILED = 100
};

private const string registryKey = @"SOFTWARE\Autodesk\SharedComponents\";

private readonly string majorRelease;
private readonly string version;
private bool fetchFromEnv;
private string installPath;
private string regPath;

/// <summary>
/// Allows the basekey to be ovrridden, used by unit tests
/// </summary>
public RegistryKey BaseKey { get; set; } = Registry.LocalMachine;

private ASC_STATUS ReadASCVersionFromEnv()
{
ASC_STATUS status = ASC_STATUS.FAILED;

var minorVersion = Environment.GetEnvironmentVariable(version);

if(minorVersion != null)
{
fetchFromEnv = true;

status = ReadASCInstallPathFromRegistry(majorRelease);

installPath = Path.Combine(installPath, minorVersion);

if(status != ASC_STATUS.SUCCESS)
{
fetchFromEnv = false;
}
}

return status;
}

private ASC_STATUS ReadASCInstallPathFromRegistry(string majorRelease)
{
ASC_STATUS status = ASC_STATUS.REG_FAILED;

var registryPath = Path.Combine(BaseKey.Name, registryKey, majorRelease);
if(string.IsNullOrEmpty(regPath))
{
regPath = registryPath;
}

const string valueName = @"InstallPath";
const string versionName = @"Version";

string installPath = Registry.GetValue(registryPath, valueName, null) as String;
if (installPath != null)
{
if (!Directory.Exists(installPath))
{
return ASC_STATUS.INCORRECT_REG_PATH;
}

if (fetchFromEnv)
{
this.installPath = installPath;
status = ASC_STATUS.SUCCESS;
}
else
{
string version = Registry.GetValue(registryPath, versionName, null) as String;
if (string.IsNullOrEmpty(version))
{
return ASC_STATUS.EMPTY_REG_VERSION;
}

this.installPath = Path.Combine(installPath, version);

if (!Directory.Exists(this.installPath))
{
return ASC_STATUS.INCORRECT_REG_PATH;
}
status = ASC_STATUS.SUCCESS;
}
}
return status;
}
/// <summary>
/// Initialize ASC wrapper
/// </summary>
/// <param name="release">Major ASC release, for example 2026</param>
public AscSdkWrapper(string release)
{
majorRelease = release;
version = @"ACS_VERSION_" + majorRelease;
}

/// <summary>
/// Get the install path for the major release
/// </summary>
/// <param name="installedPath">The install path for the major release if successful</param>
/// <returns>ASC_STATUS.SUCCESS if path was retrived successfully</returns>
public ASC_STATUS GetInstalledPath(ref string installedPath)
{
if(string.IsNullOrEmpty(majorRelease))
{
return ASC_STATUS.INITIALIZE_FAILED;
}

var status = ReadASCVersionFromEnv() == ASC_STATUS.SUCCESS ? ASC_STATUS.SUCCESS : ReadASCInstallPathFromRegistry(majorRelease);
installedPath = installPath;

return status;
}

/// <summary>
/// Get the major version of all ASC packages installed on the local machine
/// </summary>
/// <returns>An array of major versions, for example ["2026, "2027", "2028"]</returns>
public static string[] GetMajorVersions()
{
string[] majorVersions = [];
var baseKey = Registry.LocalMachine;
var subkey = baseKey.OpenSubKey(@"SOFTWARE\Autodesk\SharedComponents");
if(subkey != null)
{
majorVersions = subkey.GetSubKeyNames();
subkey.Close();
}
return majorVersions;
}
}
}
56 changes: 56 additions & 0 deletions src/Tools/DynamoInstallDetective/ProductLookUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,62 @@ public virtual Tuple<int, int, int, int> GetVersionInfoFromFile(string filePath)
}
}

#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
///
/// Helper class for looking up the install directories for all installed ASC components
///
public class InstalledAscLookUp : InstalledProductLookUp
{
const string asc = @"Autodesk Shared Components";

/// <summary>
/// Constructor
/// </summary>
/// <param name="fileLookup">File to look for</param>
public InstalledAscLookUp(string fileLookup) : base(asc, fileLookup)
{
}

/// <summary>
/// Get all major ASC versions
/// </summary>
/// <returns></returns>
internal override IEnumerable<(string DisplayName, string ProductKey)> GetProductNameAndCodeList()
{
var list = AscSdkWrapper.GetMajorVersions().Select(x => (DisplayName: x, ProductKey: string.Empty));
return list;
}

/// <summary>
/// The result is never used but still needs to be overridden
/// </summary>
/// <returns></returns>
public override IEnumerable<string> GetProductNameList()
{
var list = new List<string>();
return list;
}

/// <summary>
/// Get the install location for the ASC component
/// </summary>
/// <param name="name">ASC major verion</param>
/// <returns></returns>
public override string GetInstallLocationFromProductName(string name)
{
AscSdkWrapper asc = new AscSdkWrapper(name);
string path = string.Empty;
if(asc.GetInstalledPath(ref path) == AscSdkWrapper.ASC_STATUS.SUCCESS)
{
return path;
}

return null;
}
}

#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/Tools/DynamoInstallDetective/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public static IEnumerable FindMultipleProductInstallations(List<string> productS
using (RegUtils.StartCache())
{
var installs = new InstalledProducts();

// Look for ASM in installed ASC packages
installs.LookUpAndInitProducts(new InstalledAscLookUp(fileSearchPattern));

// Look up products with ASM installed on user's computer
foreach (var productSearchPattern in productSearchPatterns)
{
Expand Down
Loading

0 comments on commit ef9bacc

Please sign in to comment.