Hello forum!
I am developing a custom package full of Zero Touch Nodes and currently, I am struggling with adding icons to my Dynamo nodes.
I am dealing with DynamoSandbox 2.19.3.6994 version.
Before doing anything, I had a look at three different resources and I noticed they are mostly different.
- https://www.youtube.com/watch?v=eKosaLv3V84&t=632s&ab_channel=AussieBIMGuru by @GavinCrump where I could see he refers to a custom node instead of a Zero Touch Node.
- Creating Icons for Custom Nodes · DynamoDS/Dynamo Wiki · GitHub I reckon this guide is what @GavinCrump explains in his YouTube video with slight differences.
- Add Icons for a Zero Touch Assembly or NodeModel assembly · DynamoDS/Dynamo Wiki · GitHub This is supposed to be the guide to add icons within our Zero Touch Nodes.
So… what have I tried so far?
Firstly, I tried with Add Icons for a Zero Touch Assembly or NodeModel assembly · DynamoDS/Dynamo Wiki · GitHub following these steps:
- Add > New Item > JuanMCillerLibraryImages.resx resource file. Important to highlight that the name of my project is JuanMCillerLibrary.
- I select in my Solution Explorer the
.resx
file and clear Custom Tool. - Within the
.resx
file, Add Resource > Add Existing File.
3.1 JuanMCillerLibrary.DynamoGeometries.MyLine.CreateLine.Large.png where:
3.1.1. JuanMCillerLibrary is the name of my project.
3.1.2. DynamoGeometries the name of my namespace.
3.1.3. MyLine the name of the class.
3.1.4. CreateLine the name of my method.
3.2 JuanMCillerLibrary.DynamoGeometries.MyLine.CreateLine.Small.png where:
3.2.1 same as above. - Within the
.resx
file, I select both images and change the Persitante into Embedded in .resx. - I open the
.csproj
file and I insert these lines of code:
<Target Name="AfterBuild">
<!-- Get System.Drawing.dll -->
<GetReferenceAssemblyPaths TargetFrameworkMoniker=".NETFramework, Version=v4.8">
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="FrameworkAssembliesPath" />
</GetReferenceAssemblyPaths>
<!-- Get assembly -->
<GetAssemblyIdentity AssemblyFiles="$(OutDir)$(TargetName).dll">
<Output TaskParameter="Assemblies" ItemName="AssemblyInfo" />
</GetAssemblyIdentity>
<!-- Generate customization dll -->
<GenerateResource SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)" UseSourcePath="true" Sources="$(ProjectDir)\Resources\JuanMCillerLibraryImages.resx" OutputResources="$(ProjectDir)\Resources\JuanMCillerLibraryImages.resources" References="$(FrameworkAssembliesPath)System.Drawing.dll" />
<AL SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)" TargetType="library" EmbedResources="$(ProjectDir)\Resources\JuanMCillerLibraryImages.resources" OutputAssembly="$(OutDir)JuanMCillerLibraryImages.customization.dll" Version="%(AssemblyInfo.Version)" />
<ItemGroup>
<Dlls Include="$(OutDir)*.dll" />
<Pdbs Include="$(OutDir)*.pdb" />
<Xmls Include="$(OutDir)*.xml" />
<Configs Include="$(OutDir)*.config" />
<PkgJson Include="$(ProjectDir)/*pkg.json" />
<DocFiles Include="$(SolutionDir)doc\**\*" />
<SourcePackage Include="$(SolutionDir)dist\$(PackageName)\**\*" />
</ItemGroup>
<!-- This copies every file to a dist folder on the solutions directory -->
<Copy SourceFiles="@(Dlls)" DestinationFolder="$(SolutionDir)dist\$(ProjectName)\bin\" />
<Copy SourceFiles="@(Pdbs)" DestinationFolder="$(SolutionDir)dist\$(ProjectName)\bin\" />
<Copy SourceFiles="@(Xmls)" DestinationFolder="$(SolutionDir)dist\$(ProjectName)\bin\" />
<Copy SourceFiles="@(Configs)" DestinationFolder="$(SolutionDir)dist\$(ProjectName)\bin\" />
<Copy SourceFiles="@(PkgJson)" DestinationFolder="$(SolutionDir)dist\$(ProjectName)" />
<Copy SourceFiles="@(DocFiles)" DestinationFolder="$(SolutionDir)dist\$(ProjectName)\doc" />
<MakeDir Directories="$(SolutionDir)dist\$(ProjectName)\dyf" />
<MakeDir Directories="$(SolutionDir)dist\$(ProjectName)\extra" />
<!-- This copies the distributed package on dist folder to the Dynamo Packages folder. -->
<Copy SourceFiles="@(SourcePackage)" DestinationFolder="$(AppData)\Dynamo\Dynamo Core\2.19\packages\$(PackageName)\%(RecursiveDir)" />
</Target>
It is also important to highlight that I only added this piece of code in the .csproj file:
<!-- Get System.Drawing.dll -->
<GetReferenceAssemblyPaths TargetFrameworkMoniker=".NETFramework, Version=v4.8">
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="FrameworkAssembliesPath" />
</GetReferenceAssemblyPaths>
<!-- Get assembly -->
<GetAssemblyIdentity AssemblyFiles="$(OutDir)$(TargetName).dll">
<Output TaskParameter="Assemblies" ItemName="AssemblyInfo" />
</GetAssemblyIdentity>
<!-- Generate customization dll -->
<GenerateResource SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)" UseSourcePath="true" Sources="$(ProjectDir)\Resources\JuanMCillerLibraryImages.resx" OutputResources="$(ProjectDir)\Resources\JuanMCillerLibraryImages.resources" References="$(FrameworkAssembliesPath)System.Drawing.dll" />
<AL SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)" TargetType="library" EmbedResources="$(ProjectDir)\Resources\JuanMCillerLibraryImages.resources" OutputAssembly="$(OutDir)JuanMCillerLibraryImages.customization.dll" Version="%(AssemblyInfo.Version)" />
The rest of the lines were previously added to deploy the distribution package accordingly.
The NET Framework that I am using in my project is 4.8.
If I save everything, reload the project and I either Build or Rebuild the solution, I am getting this error:
Severity Code Description Project File Line Suppression State
Error This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT https://aka.ms/msbuild/unhandled
Microsoft.Build.Framework.InternalErrorException: MSB0001: Internal MSBuild Error: There should be resource files to process
at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Exception innerException, Object[] args)
at Microsoft.Build.Tasks.GenerateResource.TransformResourceFilesUsingResGen(List`1 inputsToProcess, List`1 outputsToProcess)
at Microsoft.Build.Tasks.GenerateResource.GenerateResourcesUsingResGen(List`1 inputsToProcess, List`1 outputsToProcess)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteBucket>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Build.BackEnd.TargetEntry.<ProcessBucket>d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__44.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Build.BackEnd.TargetBuilder.<ProcessTargetStack>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Build.BackEnd.TargetBuilder.<BuildTargets>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Build.BackEnd.RequestBuilder.<BuildAndReport>d__59.MoveNext() JuanMCillerLibrary
The funny thing is that if I insert this BeforeBuild coming from this page Creating Icons for Custom Nodes · DynamoDS/Dynamo Wiki · GitHub instead of the AfterBuild I attached before, the Package.customization.dll file is created in the bin folder.
<Target Name="BeforeBuild">
<GetReferenceAssemblyPaths TargetFrameworkMoniker=".NETFramework, Version=v2.0">
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="FrameworkAssembliesPath" />
</GetReferenceAssemblyPaths>
<GenerateResource SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)" UseSourcePath="true" Sources="$(ProjectDir)PackageImages.resx" OutputResources="$(ProjectDir)PackageImages.resources" References="$(FrameworkAssembliesPath)System.Drawing.dll" />
<GenerateResource UseSourcePath="true" Sources="$(ProjectDir)PackageImages.resx" OutputResources="$(ProjectDir)PackageImages.resources" References="$(FrameworkAssembliesPath)System.Drawing.dll" />
<AL TargetType="library" EmbedResources="$(ProjectDir)PackageImages.resources" OutputAssembly="$(OutDir)Package.customization.dll" />
</Target>
<Target Name="AfterBuild">
</Target>
Thanks in advance for the help.
Cheers.