├── Directory.Build.props ├── Build ├── .nuke │ ├── parameters.json │ └── build.schema.json ├── build.cmd ├── Build.cs ├── .editorconfig ├── Build.csproj ├── build.sh └── build.ps1 ├── RevitAddin.CommandLoader ├── Resources │ ├── CommandLoader.ico │ └── CommandLoader.tiff ├── Services │ ├── CodeDom │ │ ├── ICodeDomService.cs │ │ ├── CodeProviderService.cs │ │ ├── CodeDomService.cs │ │ └── CodeAnalysisCodeDomService.cs │ ├── CodeDomFactory.cs │ ├── JsonService.cs │ └── GistGithubUtils.cs ├── Revit │ ├── InfoCenterUtils.cs │ ├── Commands │ │ ├── Command.cs │ │ ├── CommandTestGist.cs │ │ ├── CommandTestGistFiles.cs │ │ └── CommandTest.cs │ ├── App.cs │ └── CodeSamples.cs ├── Views │ ├── CompileView.xaml.cs │ └── CompileView.xaml ├── Extensions │ ├── AppName.cs │ ├── AutodeskIconGeneratorUtils.cs │ └── AttributeExtension.cs ├── ViewModels │ └── CompileViewModel.cs └── RevitAddin.CommandLoader.csproj ├── .github └── workflows │ └── Build.yml ├── RevitAddin.CommandLoader.Tests ├── CodeDom │ ├── CodeDomTester.cs │ └── CodeTester.cs ├── CodeDomTests.cs ├── GistGithubUtilsTests.cs └── RevitAddin.CommandLoader.Tests.csproj ├── LICENSE ├── .gitattributes ├── CHANGELOG.md ├── RevitAddin.CommandLoader.sln ├── README.md └── .gitignore /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.2.0 4 | 5 | -------------------------------------------------------------------------------- /Build/.nuke/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./build.schema.json", 3 | "Solution": "../RevitAddin.CommandLoader.sln" 4 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Resources/CommandLoader.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricaun-io/RevitAddin.CommandLoader/HEAD/RevitAddin.CommandLoader/Resources/CommandLoader.ico -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Resources/CommandLoader.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricaun-io/RevitAddin.CommandLoader/HEAD/RevitAddin.CommandLoader/Resources/CommandLoader.tiff -------------------------------------------------------------------------------- /Build/build.cmd: -------------------------------------------------------------------------------- 1 | :; set -eo pipefail 2 | :; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) 3 | :; ${SCRIPT_DIR}/build.sh "$@" 4 | :; exit $? 5 | 6 | @ECHO OFF 7 | powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* 8 | -------------------------------------------------------------------------------- /Build/Build.cs: -------------------------------------------------------------------------------- 1 | using Nuke.Common; 2 | using Nuke.Common.Execution; 3 | using ricaun.Nuke; 4 | using ricaun.Nuke.Components; 5 | 6 | class Build : NukeBuild, IPublishRevit, ITest, IGitPreRelease 7 | { 8 | string IHazRevitPackageBuilder.Application => "Revit.App"; 9 | public static int Main() => Execute(x => x.From().Build); 10 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Services/CodeDom/ICodeDomService.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace RevitAddin.CommandLoader.Services.CodeDom 4 | { 5 | public interface ICodeDomService 6 | { 7 | Assembly GenerateCode(params string[] sourceCode); 8 | public ICodeDomService SetDefines(params string[] defines); 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /Build/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | dotnet_style_qualification_for_field = false:warning 3 | dotnet_style_qualification_for_property = false:warning 4 | dotnet_style_qualification_for_method = false:warning 5 | dotnet_style_qualification_for_event = false:warning 6 | dotnet_style_require_accessibility_modifiers = never:warning 7 | 8 | csharp_style_expression_bodied_methods = true:silent 9 | csharp_style_expression_bodied_properties = true:warning 10 | csharp_style_expression_bodied_indexers = true:warning 11 | csharp_style_expression_bodied_accessors = true:warning 12 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Services/CodeDomFactory.cs: -------------------------------------------------------------------------------- 1 | using RevitAddin.CommandLoader.Services.CodeDom; 2 | 3 | namespace RevitAddin.CommandLoader.Services 4 | { 5 | public class CodeDomFactory 6 | { 7 | public static ICodeDomService Instance { get; private set; } = CreateCodeDomService(); 8 | 9 | private static ICodeDomService CreateCodeDomService() 10 | { 11 | #if NET8_0_OR_GREATER 12 | return new CodeAnalysisCodeDomService(); 13 | #else 14 | var provider = CodeProviderService.GetCSharpCodeProvider(); 15 | return new CodeDomService(provider); 16 | #endif 17 | } 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /Build/Build.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net8.0 5 | 6 | CS0649;CS0169 7 | . 8 | . 9 | 1 10 | Debug;Release 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Revit/InfoCenterUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RevitAddin.CommandLoader.Revit 4 | { 5 | public static class InfoCenterUtils 6 | { 7 | public static void ShowBalloon(string title, string category = null, string uriString = null) 8 | { 9 | if (title == null) return; 10 | Autodesk.Internal.InfoCenter.ResultItem ri = new Autodesk.Internal.InfoCenter.ResultItem(); 11 | ri.Category = category ?? typeof(InfoCenterUtils).Assembly.GetName().Name; 12 | ri.Title = title.Trim(); 13 | if (Uri.TryCreate(uriString, UriKind.RelativeOrAbsolute, out Uri uri)) 14 | ri.Uri = uri; 15 | Autodesk.Windows.ComponentManager.InfoCenterPaletteManager.ShowBalloon(ri); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/workflows/Build.yml: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # Build.yml 3 | # ------------------------------------------------------------------------------ 4 | 5 | name: Build 6 | 7 | on: 8 | push: 9 | pull_request: 10 | branches-ignore: 11 | - master 12 | - main 13 | workflow_dispatch: 14 | 15 | jobs: 16 | Build: 17 | name: Build 18 | runs-on: windows-latest 19 | steps: 20 | - uses: actions/checkout@v1 21 | - name: Run './build/build.cmd' 22 | run: ./build/build.cmd --root ./build 23 | env: 24 | GitHubToken: ${{ secrets.GITHUB_TOKEN }} 25 | SignFile: ${{ secrets.SIGN_FILE }} 26 | SignPassword: ${{ secrets.SIGN_PASSWORD }} 27 | InstallationFiles: ${{ secrets.INSTALLATION_FILES }} -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Views/CompileView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace RevitAddin.CommandLoader.Views 5 | { 6 | public partial class CompileView : Window 7 | { 8 | public CompileView() 9 | { 10 | InitializeComponent(); 11 | InitializeWindow(); 12 | this.KeyDown += (s, e) => { if (e.Key == System.Windows.Input.Key.Escape) { this.Close(); } }; 13 | } 14 | 15 | #region InitializeWindow 16 | private void InitializeWindow() 17 | { 18 | this.SizeToContent = SizeToContent.WidthAndHeight; 19 | this.ShowInTaskbar = false; 20 | this.ResizeMode = ResizeMode.NoResize; 21 | this.WindowStartupLocation = WindowStartupLocation.CenterScreen; 22 | } 23 | #endregion 24 | } 25 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Revit/Commands/Command.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.Attributes; 2 | using Autodesk.Revit.DB; 3 | using Autodesk.Revit.UI; 4 | using System; 5 | using System.ComponentModel; 6 | using System.Threading.Tasks; 7 | 8 | namespace RevitAddin.CommandLoader.Revit.Commands 9 | { 10 | [DisplayName("Command Open - CompileView")] 11 | [Transaction(TransactionMode.Manual)] 12 | public class Command : IExternalCommand, IExternalCommandAvailability 13 | { 14 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 15 | { 16 | UIApplication uiapp = commandData.Application; 17 | 18 | ViewModels.CompileViewModel.ViewModel.Show(); 19 | 20 | return Result.Succeeded; 21 | } 22 | 23 | public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) 24 | { 25 | return true; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader.Tests/CodeDom/CodeDomTester.cs: -------------------------------------------------------------------------------- 1 | using RevitAddin.CommandLoader.Services.CodeDom; 2 | using System.Reflection; 3 | 4 | namespace RevitAddin.CommandLoader.Tests.CodeDom 5 | { 6 | public class CodeDomTester 7 | { 8 | private readonly ICodeDomService codeDomService; 9 | private readonly CodeTester codeTester; 10 | 11 | public CodeDomTester(ICodeDomService codeDomService, CodeTester codeTester) 12 | { 13 | this.codeDomService = codeDomService; 14 | this.codeTester = codeTester; 15 | } 16 | 17 | public Assembly GenerateCode() 18 | { 19 | var assembly = codeDomService 20 | .SetDefines(codeTester.Defines) 21 | .GenerateCode(codeTester.Code); 22 | return assembly; 23 | } 24 | 25 | public bool Test() 26 | { 27 | var assembly = GenerateCode(); 28 | return codeTester.HasMethodTest(assembly) && codeTester.HasMethodDebug(assembly); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ricaun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Extensions/AppName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace RevitAddin.CommandLoader.Extensions 5 | { 6 | public static class AppName 7 | { 8 | public static string GetNameVersion() 9 | { 10 | var assembly = Assembly.GetExecutingAssembly(); 11 | return $"{assembly.GetName().Name} {assembly.GetName().Version.ToString(3)}"; 12 | } 13 | 14 | public static string GetIcon() 15 | { 16 | return "Resources/CommandLoader.tiff"; 17 | } 18 | 19 | public static string GetInfo() 20 | { 21 | var assembly = Assembly.GetExecutingAssembly(); 22 | var assemblyName = assembly.GetName(); 23 | var result = $"App: {assemblyName.Name}\n"; 24 | result += $"Version: {assemblyName.Version.ToString(3)}\n"; 25 | result += $"Location: {assembly.Location}"; 26 | 27 | return result; 28 | } 29 | 30 | public static string GetUri() 31 | { 32 | return "https://github.com/ricaun-io/RevitAddin.CommandLoader"; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Revit/Commands/CommandTestGist.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.Attributes; 2 | using Autodesk.Revit.DB; 3 | using Autodesk.Revit.UI; 4 | using RevitAddin.CommandLoader.Services; 5 | using System; 6 | using System.ComponentModel; 7 | 8 | namespace RevitAddin.CommandLoader.Revit.Commands 9 | { 10 | [DisplayName("Command Test - Compile Gist")] 11 | [Transaction(TransactionMode.Manual)] 12 | public class CommandTestGist : IExternalCommand 13 | { 14 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 15 | { 16 | UIApplication uiapp = commandData.Application; 17 | 18 | var gistUrl = "https://gist.github.com/ricaun/4f62b8650d29f1ff837e7e77f9e8b552"; 19 | 20 | GistGithubUtils.TryGetGistString(gistUrl, out string gistContent); 21 | 22 | try 23 | { 24 | var codeDomService = CodeDomFactory.Instance; 25 | var assembly = codeDomService.GenerateCode(gistContent); 26 | 27 | App.CreateCommands(assembly); 28 | } 29 | catch (System.Exception ex) 30 | { 31 | System.Windows.MessageBox.Show(ex.ToString()); 32 | } 33 | 34 | return Result.Succeeded; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader.Tests/CodeDomTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using RevitAddin.CommandLoader.Services; 3 | using RevitAddin.CommandLoader.Services.CodeDom; 4 | using RevitAddin.CommandLoader.Tests.CodeDom; 5 | using System; 6 | 7 | namespace RevitAddin.CommandLoader.Tests 8 | { 9 | public class CodeDomTests 10 | { 11 | CodeTester CodeTester = new CodeTester(); 12 | 13 | public void Test_ICodeDomService(ICodeDomService codeDomService) 14 | { 15 | var assembly = codeDomService 16 | .SetDefines(CodeTester.Defines) 17 | .GenerateCode(CodeTester.Code); 18 | 19 | Console.WriteLine(assembly); 20 | 21 | Assert.IsTrue(CodeTester.HasMethodTest(assembly), "Test method not found."); 22 | Assert.IsTrue(CodeTester.HasMethodDebug(assembly), "Debug method not found."); 23 | 24 | Assert.IsTrue(CodeTester.HasMethodTest2(assembly), "Test method not found in the Tests2 class."); 25 | Assert.IsTrue(CodeTester.HasMethodDebug2(assembly), "Debug method not found in the Tests2 class."); 26 | } 27 | 28 | [Test] 29 | public void Test_CodeDomService() 30 | { 31 | var codeDomService = CodeDomFactory.Instance; 32 | Test_ICodeDomService(codeDomService); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Views/CompileView.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 24 | 25 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Revit/Commands/CommandTestGistFiles.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.Attributes; 2 | using Autodesk.Revit.DB; 3 | using Autodesk.Revit.UI; 4 | using RevitAddin.CommandLoader.Services; 5 | using System.ComponentModel; 6 | 7 | namespace RevitAddin.CommandLoader.Revit.Commands 8 | { 9 | [DisplayName("Command Test - Compile Gist Files")] 10 | [Transaction(TransactionMode.Manual)] 11 | public class CommandTestGistFiles : IExternalCommand 12 | { 13 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 14 | { 15 | UIApplication uiapp = commandData.Application; 16 | 17 | var gistUrlFiles = "https://gist.github.com/ricaun/14ec0730e7efb3cc737f2134475e2539"; 18 | 19 | GistGithubUtils.TryGetGistFilesContent(gistUrlFiles, out string[] gistFilesContent); 20 | 21 | try 22 | { 23 | System.Console.WriteLine(gistFilesContent.Length); 24 | var codeDomService = CodeDomFactory.Instance; 25 | var assembly = codeDomService.GenerateCode(gistFilesContent); 26 | 27 | App.CreateCommands(assembly); 28 | } 29 | catch (System.Exception ex) 30 | { 31 | System.Windows.MessageBox.Show(ex.ToString()); 32 | } 33 | 34 | return Result.Succeeded; 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader.Tests/CodeDom/CodeTester.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace RevitAddin.CommandLoader.Tests.CodeDom 4 | { 5 | public class CodeTester 6 | { 7 | const string code = """ 8 | using System; 9 | public class Tests 10 | { 11 | public void Test() { } 12 | #if DEBUG 13 | public void Debug() { } 14 | #endif 15 | } 16 | """; 17 | const string code2 = """ 18 | using System; 19 | public class Tests2 20 | { 21 | public void Test() { } 22 | #if DEBUG 23 | public void Debug() { } 24 | #endif 25 | } 26 | """; 27 | public string[] Code => new[] { code, code2 }; 28 | public string[] Defines => new[] { "DEBUG" }; 29 | public bool HasMethodTest(Assembly assembly) 30 | { 31 | var method = assembly.GetType("Tests")?.GetMethod("Test"); 32 | return method is not null; 33 | } 34 | public bool HasMethodDebug(Assembly assembly) 35 | { 36 | var method = assembly.GetType("Tests")?.GetMethod("Debug"); 37 | return method is not null; 38 | } 39 | public bool HasMethodTest2(Assembly assembly) 40 | { 41 | var method = assembly.GetType("Tests2")?.GetMethod("Test"); 42 | return method is not null; 43 | } 44 | public bool HasMethodDebug2(Assembly assembly) 45 | { 46 | var method = assembly.GetType("Tests2")?.GetMethod("Debug"); 47 | return method is not null; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader.Tests/GistGithubUtilsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using RevitAddin.CommandLoader.Services; 3 | using System; 4 | 5 | namespace RevitAddin.CommandLoader.Tests 6 | { 7 | public class GistGithubUtilsTests 8 | { 9 | private const string GIST_SOURCE = "https://gist.github.com/ricaun/200a576c3baa45cba034ceedac1e708e"; 10 | 11 | [Test] 12 | public void Test_TryGetGistFilesContent() 13 | { 14 | var hasGistContent = GistGithubUtils.TryGetGistFilesContent(GIST_SOURCE, out string[] contents); 15 | Assert.IsTrue(hasGistContent, "Gist content not found."); 16 | } 17 | 18 | [Test] 19 | public void Test_TryGetGistModel() 20 | { 21 | var hasGistContent = GistGithubUtils.TryGetGistModel(GIST_SOURCE, out var model); 22 | Assert.IsTrue(hasGistContent, "Gist content not found."); 23 | } 24 | 25 | [Test] 26 | public void Test_TryGetGistId() 27 | { 28 | var hasGistContent = GistGithubUtils.TryGetGistId(GIST_SOURCE, out var id); 29 | Assert.IsTrue(hasGistContent, "Gist content not found."); 30 | Console.WriteLine(id); 31 | } 32 | 33 | [Test] 34 | public void Test_TryGetGistString() 35 | { 36 | var hasGistContent = GistGithubUtils.TryGetGistString(GIST_SOURCE, out string content); 37 | Assert.IsTrue(hasGistContent, "Gist content not found."); 38 | } 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Revit/Commands/CommandTest.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.Attributes; 2 | using Autodesk.Revit.DB; 3 | using Autodesk.Revit.UI; 4 | using RevitAddin.CommandLoader.Services; 5 | using System.ComponentModel; 6 | using System.IO; 7 | using System.Reflection; 8 | 9 | namespace RevitAddin.CommandLoader.Revit.Commands 10 | { 11 | [DisplayName("Command Test - Compile and Ribbon")] 12 | [Transaction(TransactionMode.Manual)] 13 | public class CommandTest : IExternalCommand, IExternalCommandAvailability 14 | { 15 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 16 | { 17 | UIApplication uiapp = commandData.Application; 18 | 19 | try 20 | { 21 | var codeDomService = CodeDomFactory.Instance; 22 | var assembly = codeDomService.GenerateCode( 23 | CodeSamples.CommandVersion, 24 | CodeSamples.CommandTask, 25 | CodeSamples.CommandDeleteWalls); 26 | 27 | App.CreateCommands(assembly); 28 | } 29 | catch (System.Exception ex) 30 | { 31 | System.Windows.MessageBox.Show(ex.ToString()); 32 | } 33 | 34 | return Result.Succeeded; 35 | } 36 | 37 | public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) 38 | { 39 | return true; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Extensions/AutodeskIconGeneratorUtils.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using System; 3 | 4 | namespace RevitAddin.CommandLoader.Extensions 5 | { 6 | public static class AutodeskIconGeneratorUtils 7 | { 8 | private static string[] icons = new[] { "Grey", "Red", "Orange", "Yellow", "Green", "Cyan", "Blue", "Purple", "Pink", "Brown" }; 9 | private static string[] types = new[] { "Box", "Cube" }; 10 | private static string[] themes = new[] { "Light", "Dark" }; 11 | private static char separetor = '-'; 12 | private static string extension = ".tiff"; 13 | private static string url = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/"; 14 | 15 | private static int icon = 0; 16 | public static bool IsDark => UIThemeManager.CurrentTheme == UITheme.Dark; 17 | public static string GetBox() 18 | { 19 | return url + CreateIcon(icon++, 0, IsDark ? 1 : 0); 20 | } 21 | 22 | public static string GetCube() 23 | { 24 | return url + CreateIcon(icon++, 1, IsDark ? 1 : 0); 25 | } 26 | 27 | private static string CreateIcon(int icon = 0, int type = 0, int theme = 0) 28 | { 29 | var typeStr = types[type % types.Length]; 30 | var iconStr = icons[icon % icons.Length]; 31 | var themeStr = themes[theme % themes.Length]; 32 | 33 | var name = $"{typeStr}{separetor}{iconStr}"; 34 | if (string.IsNullOrEmpty(themeStr) == false) 35 | name += $"{separetor}{themeStr}"; 36 | 37 | return $"{name}{extension}"; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Services/CodeDom/CodeProviderService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CSharp; 2 | using System.CodeDom.Compiler; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | 6 | namespace RevitAddin.CommandLoader.Services.CodeDom 7 | { 8 | public class CodeProviderService 9 | { 10 | public static CodeDomProvider GetCSharpCodeProvider(bool useLegacyCodeDom = false) 11 | { 12 | #if NET48_OR_GREATER 13 | if (!useLegacyCodeDom) 14 | { 15 | return NewCSharpCodeProvider(); 16 | } 17 | #endif 18 | return new CSharpCodeProvider(); 19 | } 20 | 21 | #if NET48_OR_GREATER 22 | /// 23 | /// NewCSharpCodeProvider 24 | /// https://github.com/aspnet/RoslynCodeDomProvider 25 | /// 26 | /// 27 | internal static CodeDomProvider NewCSharpCodeProvider() 28 | { 29 | var compilerSettings = new ProviderOptions() 30 | { 31 | CompilerFullPath = CompilerFullPath(@"roslyn/csc.exe"), 32 | CompilerServerTimeToLive = 300 33 | }; 34 | return new Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider(compilerSettings); 35 | } 36 | internal class ProviderOptions : Microsoft.CodeDom.Providers.DotNetCompilerPlatform.IProviderOptions 37 | { 38 | public string CompilerFullPath { get; set; } 39 | public int CompilerServerTimeToLive { get; set; } 40 | public string CompilerVersion { get; set; } 41 | public bool WarnAsError { get; set; } 42 | public bool UseAspNetSettings { get; set; } 43 | public IDictionary AllOptions { get; set; } 44 | } 45 | private static string CompilerFullPath(string relativePath) 46 | { 47 | string frameworkFolder = Path.GetDirectoryName(typeof(CodeDomService).Assembly.Location); 48 | string compilerFullPath = Path.Combine(frameworkFolder, relativePath); 49 | 50 | return compilerFullPath; 51 | } 52 | #endif 53 | } 54 | } -------------------------------------------------------------------------------- /Build/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bash --version 2>&1 | head -n 1 4 | 5 | set -eo pipefail 6 | SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) 7 | 8 | ########################################################################### 9 | # CONFIGURATION 10 | ########################################################################### 11 | 12 | BUILD_PROJECT_FILE="$SCRIPT_DIR/Build.csproj" 13 | TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" 14 | 15 | DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" 16 | DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" 17 | DOTNET_CHANNEL="Current" 18 | 19 | export DOTNET_CLI_TELEMETRY_OPTOUT=1 20 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 21 | export DOTNET_MULTILEVEL_LOOKUP=0 22 | 23 | ########################################################################### 24 | # EXECUTION 25 | ########################################################################### 26 | 27 | function FirstJsonValue { 28 | perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" 29 | } 30 | 31 | # If dotnet CLI is installed globally and it matches requested version, use for execution 32 | if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then 33 | export DOTNET_EXE="$(command -v dotnet)" 34 | else 35 | # Download install script 36 | DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" 37 | mkdir -p "$TEMP_DIRECTORY" 38 | curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" 39 | chmod +x "$DOTNET_INSTALL_FILE" 40 | 41 | # If global.json exists, load expected version 42 | if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then 43 | DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") 44 | if [[ "$DOTNET_VERSION" == "" ]]; then 45 | unset DOTNET_VERSION 46 | fi 47 | fi 48 | 49 | # Install by channel or version 50 | DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" 51 | if [[ -z ${DOTNET_VERSION+x} ]]; then 52 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path 53 | else 54 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path 55 | fi 56 | export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" 57 | fi 58 | 59 | echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" 60 | 61 | "$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet 62 | "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" 63 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Services/CodeDom/CodeDomService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.CodeDom.Compiler; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Reflection; 7 | 8 | namespace RevitAddin.CommandLoader.Services.CodeDom 9 | { 10 | public class CodeDomService : ICodeDomService 11 | { 12 | private CodeDomProvider provider; 13 | 14 | public CodeDomService(CodeDomProvider provider) 15 | { 16 | this.provider = provider; 17 | } 18 | private string CompilerOptions { get; set; } 19 | public ICodeDomService SetDefines(params string[] defines) 20 | { 21 | CompilerOptions = $" /define:{string.Join(";", defines).Replace(" ", "")}"; 22 | return this; 23 | } 24 | 25 | public Assembly GenerateCode(params string[] sourceCode) 26 | { 27 | var compilationUnits = sourceCode 28 | .Select(s => new CodeSnippetCompileUnit(s)) 29 | .ToArray(); 30 | 31 | return GenerateCode(compilationUnits); 32 | } 33 | 34 | public Assembly GenerateCode(params CodeCompileUnit[] compilationUnits) 35 | { 36 | CompilerParameters compilerParametes = new CompilerParameters(); 37 | 38 | compilerParametes.GenerateExecutable = false; 39 | compilerParametes.IncludeDebugInformation = false; 40 | compilerParametes.GenerateInMemory = false; 41 | 42 | compilerParametes.CompilerOptions = CompilerOptions; 43 | 44 | #region Add GetReferencedAssemblies 45 | var assemblyNames = Assembly.GetExecutingAssembly().GetReferencedAssemblies(); 46 | var nameAssemblies = new Dictionary(); 47 | foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) 48 | { 49 | if (assemblyNames.Any(e => e.Name == assembly.GetName().Name)) 50 | { 51 | nameAssemblies[assembly.GetName().Name] = assembly; 52 | } 53 | } 54 | foreach (var keyAssembly in nameAssemblies) 55 | { 56 | compilerParametes.ReferencedAssemblies.Add(keyAssembly.Value.Location); 57 | } 58 | 59 | #endregion 60 | 61 | CompilerResults results = provider.CompileAssemblyFromDom(compilerParametes, compilationUnits); 62 | return results.CompiledAssembly; 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.2.0] / 2025-03-21 8 | ### Features 9 | - Support `tiff` image files. 10 | ### Updates 11 | - Using `ricaun.Revit.UI` to `0.8.0`. 12 | - Update `AutodeskIconGeneratorUtils` to use version `2.0.0` and `tiff` file. 13 | - Add `CommandLoader.tiff` as the default image icon. 14 | 15 | ## [1.1.1] / 2024-02-27 16 | ### Features 17 | - Support [Autodesk.Icon](https://github.com/ricaun-io/Autodesk.Icon.Example) in dark theme. 18 | ### Updated 19 | - Add `AutodeskIconGeneratorUtils`. 20 | - Window close with `Esc` key. 21 | 22 | ## [1.1.0] / 2024-02-17 23 | ### Features 24 | - Support net core plugin. 25 | ### Added 26 | - Add `CodeAnalysisCodeDom` to support net code. 27 | - Update `CodeAnalysisCodeDomService` to work with multiple source code. 28 | ### Tests 29 | - Test `GistGithubUtils` download string. 30 | - Add `Newtonsoft.Json` to support `GistGithubUtils` download string. 31 | 32 | ## [1.0.6] / 2024-01-27 33 | ### Features 34 | - Using `ricaun.Revit.UI.Tasks` 35 | ### Tests 36 | - Add `CodeDom` simple test. 37 | ### Updated 38 | - Add `ICodeDomService` interface 39 | - Add `CodeDomFactory` class 40 | ### Remove 41 | - Remove `Revit.Async` 42 | 43 | ## [1.0.5] / 2023-05-05 44 | ### Features 45 | - Support C# version 7.3 in Revit 2021+ with `DotNetCompilerPlatform`. 46 | - Gist Download Files and compile. 47 | - Support `CodeDomService` with Defines - `Revit20$$` and `REVIT20$$`. 48 | ### Updated 49 | - Update `InfoCenterUtils` to show download update. 50 | 51 | ## [1.0.4] / 2023-02-03 52 | ### Updated 53 | - Update example `Command` to `Revit Version` 54 | 55 | ## [1.0.3] / 2023-02-02 56 | ### Updated 57 | - Remove Version in the `Release` folder 58 | 59 | ## [1.0.2] / 2023-02-02 60 | ### Fixed 61 | - Fix `GithubRequestService` repository 62 | 63 | ## [1.0.1] / 2023-02-02 64 | ### Added 65 | - Add Debug color Panel Title Background 66 | ### Fixed 67 | - Fix Image load problem 68 | 69 | ## [1.0.0] / 2023-02-02 70 | ### Features 71 | - [x] Compile multiple `IExternalCommand` UI 72 | - [x] Code Compiler 73 | - [x] Add Command to Ribbon 74 | - [x] AutoUpdater 75 | 76 | [vNext]: ../../compare/1.0.0...HEAD 77 | [1.2.0]: ../../compare/1.1.1...1.2.0 78 | [1.1.1]: ../../compare/1.1.0...1.1.1 79 | [1.1.0]: ../../compare/1.0.6...1.1.0 80 | [1.0.6]: ../../compare/1.0.5...1.0.6 81 | [1.0.5]: ../../compare/1.0.4...1.0.5 82 | [1.0.4]: ../../compare/1.0.3...1.0.4 83 | [1.0.3]: ../../compare/1.0.2...1.0.3 84 | [1.0.2]: ../../compare/1.0.1...1.0.2 85 | [1.0.1]: ../../compare/1.0.0...1.0.1 86 | [1.0.0]: ../../compare/1.0.0 -------------------------------------------------------------------------------- /Build/build.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | Param( 3 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] 4 | [string[]]$BuildArguments 5 | ) 6 | 7 | Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" 8 | 9 | Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } 10 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 11 | 12 | ########################################################################### 13 | # CONFIGURATION 14 | ########################################################################### 15 | 16 | $BuildProjectFile = "$PSScriptRoot\Build.csproj" 17 | $TempDirectory = "$PSScriptRoot\\.nuke\temp" 18 | 19 | $DotNetGlobalFile = "$PSScriptRoot\\global.json" 20 | $DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" 21 | $DotNetChannel = "Current" 22 | 23 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 24 | $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 25 | $env:DOTNET_MULTILEVEL_LOOKUP = 0 26 | 27 | ########################################################################### 28 | # EXECUTION 29 | ########################################################################### 30 | 31 | function ExecSafe([scriptblock] $cmd) { 32 | & $cmd 33 | if ($LASTEXITCODE) { exit $LASTEXITCODE } 34 | } 35 | 36 | # If dotnet CLI is installed globally and it matches requested version, use for execution 37 | if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` 38 | $(dotnet --version) -and $LASTEXITCODE -eq 0) { 39 | $env:DOTNET_EXE = (Get-Command "dotnet").Path 40 | } 41 | else { 42 | # Download install script 43 | $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" 44 | New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null 45 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 46 | (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) 47 | 48 | # If global.json exists, load expected version 49 | if (Test-Path $DotNetGlobalFile) { 50 | $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) 51 | if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { 52 | $DotNetVersion = $DotNetGlobal.sdk.version 53 | } 54 | } 55 | 56 | # Install by channel or version 57 | $DotNetDirectory = "$TempDirectory\dotnet-win" 58 | if (!(Test-Path variable:DotNetVersion)) { 59 | ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } 60 | } else { 61 | ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } 62 | } 63 | $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" 64 | } 65 | 66 | Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" 67 | 68 | ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } 69 | ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } 70 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Services/CodeDom/CodeAnalysisCodeDomService.cs: -------------------------------------------------------------------------------- 1 | #if NET8_0_OR_GREATER 2 | 3 | using Microsoft.CodeAnalysis; 4 | using Microsoft.CodeAnalysis.CSharp; 5 | using Microsoft.CodeAnalysis.Text; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Reflection; 11 | 12 | namespace RevitAddin.CommandLoader.Services.CodeDom 13 | { 14 | public class CodeAnalysisCodeDomService : ICodeDomService 15 | { 16 | private string[] PreprocessorSymbols { get; set; } 17 | public ICodeDomService SetDefines(params string[] defines) 18 | { 19 | PreprocessorSymbols = defines; 20 | return this; 21 | } 22 | 23 | public Assembly GenerateCode(params string[] sourceCode) 24 | { 25 | var compilation = CompilationCode(sourceCode, PreprocessorSymbols); 26 | 27 | var filePath = Path.Combine(Path.GetTempPath(), compilation.Assembly.Name + ".dll"); 28 | using (var file = File.Create(filePath)) 29 | { 30 | var result = compilation.Emit(file); 31 | } 32 | 33 | return Assembly.LoadFrom(filePath); 34 | } 35 | 36 | private CSharpCompilation CompilationCode(string[] sourceCodes, string[] preprocessorSymbols = null) 37 | { 38 | var options = CSharpParseOptions.Default 39 | .WithLanguageVersion(LanguageVersion.Latest) 40 | .WithPreprocessorSymbols(preprocessorSymbols); 41 | 42 | var parsedSyntaxTrees = sourceCodes 43 | .Select(sourceCode => SyntaxFactory.ParseSyntaxTree(sourceCode, options)) 44 | .ToArray(); 45 | 46 | var references = new List 47 | { 48 | MetadataReference.CreateFromFile(typeof(object).Assembly.Location), 49 | MetadataReference.CreateFromFile(typeof(Console).Assembly.Location) 50 | }; 51 | 52 | #region Add GetReferencedAssemblies 53 | var assemblyNames = Assembly.GetExecutingAssembly().GetReferencedAssemblies(); 54 | var nameAssemblies = new Dictionary(); 55 | foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) 56 | { 57 | if (assemblyNames.Any(e => e.Name == assembly.GetName().Name)) 58 | { 59 | nameAssemblies[assembly.GetName().Name] = assembly; 60 | } 61 | } 62 | foreach (var keyAssembly in nameAssemblies) 63 | { 64 | references.Add(MetadataReference.CreateFromFile(keyAssembly.Value.Location)); 65 | } 66 | #endregion 67 | 68 | return CSharpCompilation.Create(Guid.NewGuid().ToString(), 69 | parsedSyntaxTrees, 70 | references: references, 71 | options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, 72 | optimizationLevel: OptimizationLevel.Release, 73 | assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default)); 74 | } 75 | } 76 | } 77 | 78 | #endif -------------------------------------------------------------------------------- /RevitAddin.CommandLoader.Tests/RevitAddin.CommandLoader.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | Latest 6 | Debug 2017;2017;Debug 2021;2021;2025;Debug 2025 7 | 8 | 9 | 10 | 11 | 12 | 13 | 2017 14 | net46 15 | 16 | 17 | 18 | 19 | 2018 20 | net46 21 | 22 | 23 | 24 | 25 | 2019 26 | net47 27 | 28 | 29 | 30 | 31 | 2020 32 | net47 33 | 34 | 35 | 36 | 37 | 2021 38 | net48 39 | 40 | 41 | 42 | 43 | 2022 44 | net48 45 | 46 | 47 | 48 | 49 | 2024 50 | net48 51 | 52 | 53 | 54 | 55 | 2025 56 | net8.0-windows 57 | 58 | 59 | 60 | 61 | 2017 62 | net46 63 | 64 | 65 | 66 | 67 | 68 | 69 | REVIT$(RevitVersion) 70 | 71 | 72 | 73 | 74 | true 75 | true 76 | false 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | NU1903 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Extensions/AttributeExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace System.Reflection 7 | { 8 | /// 9 | /// A static class containing methods for working with custom attributes. 10 | /// 11 | public static class AttributeExtension 12 | { 13 | /// 14 | /// Checks if a custom attribute provider has any attributes of the specified type. 15 | /// 16 | /// The type of attribute to check for. 17 | /// The custom attribute provider. 18 | /// True if the custom attribute provider has any attributes of the specified type, false otherwise. 19 | public static bool AnyAttribute( 20 | this ICustomAttributeProvider customAttributeProvider) 21 | where TCustomAttributeType : Attribute 22 | { 23 | return GetAttribute(customAttributeProvider) is not null; 24 | } 25 | /// 26 | /// Gets attributes of the specified type from a custom attribute provider. 27 | /// 28 | /// The type of attribute to get. 29 | /// The custom attribute provider. 30 | /// The attributes of the specified type from the custom attribute provider. 31 | public static IEnumerable GetAttributes( 32 | this ICustomAttributeProvider customAttributeProvider) 33 | where TCustomAttributeType : Attribute 34 | { 35 | return customAttributeProvider 36 | .GetCustomAttributes(typeof(TCustomAttributeType), true) 37 | .OfType(); 38 | } 39 | /// 40 | /// Gets the first attribute of the specified type from a custom attribute provider. 41 | /// 42 | /// The type of attribute to get. 43 | /// The custom attribute provider. 44 | /// The first attribute of the specified type from the custom attribute provider. 45 | public static TCustomAttributeType GetAttribute( 46 | this ICustomAttributeProvider customAttributeProvider) 47 | where TCustomAttributeType : Attribute 48 | { 49 | return customAttributeProvider 50 | .GetAttributes() 51 | .FirstOrDefault(); 52 | } 53 | /// 54 | /// Tries to get the first attribute of the specified type from a custom attribute provider. 55 | /// 56 | /// The type of attribute to get. 57 | /// The custom attribute provider. 58 | /// The first attribute of the specified type from the custom attribute provider. 59 | /// True if the attribute was found, false otherwise. 60 | public static bool TryGetAttribute( 61 | this ICustomAttributeProvider customAttributeProvider, 62 | out TCustomAttributeType customAttributeType) 63 | where TCustomAttributeType : Attribute 64 | { 65 | customAttributeType = GetAttribute(customAttributeProvider); 66 | return customAttributeType is not null; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Services/JsonService.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitAddin.CommandLoader.Services 4 | { 5 | /// 6 | /// JsonService 7 | /// 8 | public class JsonService : JsonService, IJsonService 9 | { 10 | 11 | } 12 | 13 | /// 14 | /// JsonService 15 | /// 16 | /// 17 | public class JsonService : IJsonService 18 | { 19 | private readonly JsonSerializerSettings settings; 20 | /// 21 | /// JsonService 22 | /// 23 | public JsonService() 24 | { 25 | settings = new JsonSerializerSettings(); 26 | } 27 | 28 | /// 29 | /// Get JsonSerializerSettings 30 | /// 31 | /// 32 | public JsonSerializerSettings GetSettings() => settings; 33 | 34 | /// 35 | /// Serialize 36 | /// 37 | /// 38 | /// 39 | public string Serialize(TJson value) 40 | { 41 | return SerializeObject(value); 42 | } 43 | 44 | /// 45 | /// SerializeObject 46 | /// 47 | /// 48 | /// 49 | /// 50 | public string SerializeObject(T value) 51 | { 52 | return JsonConvert.SerializeObject(value, settings); 53 | } 54 | 55 | /// 56 | /// Deserialize 57 | /// 58 | /// 59 | /// 60 | public TJson Deserialize(string value) 61 | { 62 | return DeserializeObject(value); 63 | } 64 | 65 | /// 66 | /// DeserializeObject 67 | /// 68 | /// 69 | /// 70 | /// 71 | public T DeserializeObject(string value) 72 | { 73 | return JsonConvert.DeserializeObject(value, settings); 74 | } 75 | } 76 | 77 | /// 78 | /// IJsonService 79 | /// 80 | public interface IJsonService : IJsonService 81 | { 82 | 83 | } 84 | 85 | /// 86 | /// IJsonService 87 | /// 88 | /// 89 | public interface IJsonService 90 | { 91 | /// 92 | /// GetSettings 93 | /// 94 | /// 95 | JsonSerializerSettings GetSettings(); 96 | 97 | /// 98 | /// Serialize 99 | /// 100 | /// 101 | /// 102 | string Serialize(TJson value); 103 | 104 | /// 105 | /// SerializeObject 106 | /// 107 | /// 108 | /// 109 | /// 110 | string SerializeObject(T value); 111 | 112 | /// 113 | /// Deserialize 114 | /// 115 | /// 116 | /// 117 | TJson Deserialize(string value); 118 | 119 | /// 120 | /// DeserializeObject 121 | /// 122 | /// 123 | /// 124 | /// 125 | T DeserializeObject(string value); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/ViewModels/CompileViewModel.cs: -------------------------------------------------------------------------------- 1 | using RevitAddin.CommandLoader.Extensions; 2 | using RevitAddin.CommandLoader.Revit; 3 | using RevitAddin.CommandLoader.Services; 4 | using RevitAddin.CommandLoader.Views; 5 | using ricaun.Revit.Mvvm; 6 | using ricaun.Revit.UI; 7 | using ricaun.Revit.UI.Drawing; 8 | using ricaun.Revit.UI.Tasks; 9 | using System; 10 | using System.Threading.Tasks; 11 | using System.Windows; 12 | 13 | namespace RevitAddin.CommandLoader.ViewModels 14 | { 15 | public class CompileViewModel : ObservableObject 16 | { 17 | #region Public Static 18 | public static CompileViewModel ViewModel { get; set; } = new CompileViewModel(); 19 | #endregion 20 | 21 | #region Public Properties 22 | public string Text { get; set; } = 23 | #if DEBUG 24 | CodeSamples.CommandThemeGist; 25 | #else 26 | CodeSamples.Command; 27 | #endif 28 | public bool EnableText { get; set; } = true; 29 | public IAsyncRelayCommand Command => new AsyncRelayCommand(CompileText); 30 | #endregion 31 | 32 | #region Constructor 33 | public CompileViewModel() 34 | { 35 | 36 | } 37 | #endregion 38 | 39 | #region View / Window 40 | public string Title { get; set; } = AppName.GetNameVersion(); 41 | public object Icon { get; set; } = AppName.GetIcon().GetBitmapSource(); 42 | public CompileView Window { get; private set; } 43 | public void Show() 44 | { 45 | if (Window is null) 46 | { 47 | Window = new CompileView(); 48 | Window.DataContext = this; 49 | Window.SetAutodeskOwner(); 50 | Window.Closed += (s, e) => { Window = null; }; 51 | InitializeCompile(); 52 | } 53 | Window?.Show(); 54 | Window?.Activate(); 55 | } 56 | #endregion 57 | 58 | #region Private Methods 59 | private async Task CompileText() 60 | { 61 | EnableText = false; 62 | 63 | var sources = new[] { Text }; 64 | 65 | if (GistGithubUtils.TryGetGistString(Text, out string gistOutput)) 66 | { 67 | sources = new[] { gistOutput }; 68 | } 69 | if (GistGithubUtils.TryGetGistFilesContent(Text, out string[] gistContents)) 70 | { 71 | sources = gistContents; 72 | } 73 | 74 | try 75 | { 76 | await App.RevitTask.Run((uiapp) => 77 | { 78 | var version = uiapp.Application.VersionNumber; 79 | try 80 | { 81 | var codeDomService = CodeDomFactory.Instance; 82 | 83 | var defines = new[] { 84 | $"REVIT{version}", 85 | $"Revit{version}", 86 | #if DEBUG 87 | "DEBUG", 88 | #endif 89 | }; 90 | 91 | var assembly = codeDomService 92 | //#if DEBUG 93 | // .SetDefines("DEBUG") 94 | //#endif 95 | // .SetDefines($"REVIT{version}", $"Revit{version}") 96 | .SetDefines(defines) 97 | .GenerateCode(sources); 98 | 99 | App.CreateCommands(assembly); 100 | } 101 | catch (System.Exception ex) 102 | { 103 | System.Windows.MessageBox.Show(ex.ToString()); 104 | } 105 | }); 106 | } 107 | finally 108 | { 109 | EnableText = true; 110 | } 111 | } 112 | 113 | private void InitializeCompile() 114 | { 115 | Task.Run(() => 116 | { 117 | CodeDomFactory.Instance.GenerateCode(CodeSamples.Command); 118 | }); 119 | } 120 | #endregion 121 | } 122 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33424.131 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitAddin.CommandLoader", "RevitAddin.CommandLoader\RevitAddin.CommandLoader.csproj", "{82070359-36DA-4441-A59D-9018B6A8B348}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "Build\Build.csproj", "{34853418-411C-4B27-82AF-DDE5309AEE10}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{E6AC2FD0-D488-44FE-9390-3CADFB37E99D}" 11 | ProjectSection(SolutionItems) = preProject 12 | CHANGELOG.md = CHANGELOG.md 13 | Directory.Build.props = Directory.Build.props 14 | LICENSE = LICENSE 15 | README.md = README.md 16 | EndProjectSection 17 | EndProject 18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitAddin.CommandLoader.Tests", "RevitAddin.CommandLoader.Tests\RevitAddin.CommandLoader.Tests.csproj", "{42C706AF-0255-4E98-A5A0-C043FA7B0496}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | 2017|Any CPU = 2017|Any CPU 23 | 2021|Any CPU = 2021|Any CPU 24 | 2025|Any CPU = 2025|Any CPU 25 | Debug 2017|Any CPU = Debug 2017|Any CPU 26 | Debug 2021|Any CPU = Debug 2021|Any CPU 27 | Debug 2025|Any CPU = Debug 2025|Any CPU 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {82070359-36DA-4441-A59D-9018B6A8B348}.2017|Any CPU.ActiveCfg = 2017|Any CPU 31 | {82070359-36DA-4441-A59D-9018B6A8B348}.2017|Any CPU.Build.0 = 2017|Any CPU 32 | {82070359-36DA-4441-A59D-9018B6A8B348}.2021|Any CPU.ActiveCfg = 2021|Any CPU 33 | {82070359-36DA-4441-A59D-9018B6A8B348}.2021|Any CPU.Build.0 = 2021|Any CPU 34 | {82070359-36DA-4441-A59D-9018B6A8B348}.2025|Any CPU.ActiveCfg = 2025|Any CPU 35 | {82070359-36DA-4441-A59D-9018B6A8B348}.2025|Any CPU.Build.0 = 2025|Any CPU 36 | {82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2017|Any CPU.ActiveCfg = Debug 2017|Any CPU 37 | {82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2017|Any CPU.Build.0 = Debug 2017|Any CPU 38 | {82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2021|Any CPU.ActiveCfg = Debug 2021|Any CPU 39 | {82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2021|Any CPU.Build.0 = Debug 2021|Any CPU 40 | {82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2025|Any CPU.ActiveCfg = Debug 2025|Any CPU 41 | {82070359-36DA-4441-A59D-9018B6A8B348}.Debug 2025|Any CPU.Build.0 = Debug 2025|Any CPU 42 | {34853418-411C-4B27-82AF-DDE5309AEE10}.2017|Any CPU.ActiveCfg = Release|Any CPU 43 | {34853418-411C-4B27-82AF-DDE5309AEE10}.2021|Any CPU.ActiveCfg = Release|Any CPU 44 | {34853418-411C-4B27-82AF-DDE5309AEE10}.2025|Any CPU.ActiveCfg = Debug|Any CPU 45 | {34853418-411C-4B27-82AF-DDE5309AEE10}.2025|Any CPU.Build.0 = Debug|Any CPU 46 | {34853418-411C-4B27-82AF-DDE5309AEE10}.Debug 2017|Any CPU.ActiveCfg = Debug|Any CPU 47 | {34853418-411C-4B27-82AF-DDE5309AEE10}.Debug 2021|Any CPU.ActiveCfg = Debug|Any CPU 48 | {34853418-411C-4B27-82AF-DDE5309AEE10}.Debug 2025|Any CPU.ActiveCfg = Debug|Any CPU 49 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.2017|Any CPU.ActiveCfg = 2017|Any CPU 50 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.2017|Any CPU.Build.0 = 2017|Any CPU 51 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.2021|Any CPU.ActiveCfg = 2021|Any CPU 52 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.2021|Any CPU.Build.0 = 2021|Any CPU 53 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.2025|Any CPU.ActiveCfg = 2025|Any CPU 54 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.2025|Any CPU.Build.0 = 2025|Any CPU 55 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.Debug 2017|Any CPU.ActiveCfg = Debug|Any CPU 56 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.Debug 2017|Any CPU.Build.0 = Debug|Any CPU 57 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.Debug 2021|Any CPU.ActiveCfg = Debug 2021|Any CPU 58 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.Debug 2021|Any CPU.Build.0 = Debug 2021|Any CPU 59 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.Debug 2025|Any CPU.ActiveCfg = Debug 2025|Any CPU 60 | {42C706AF-0255-4E98-A5A0-C043FA7B0496}.Debug 2025|Any CPU.Build.0 = Debug 2025|Any CPU 61 | EndGlobalSection 62 | GlobalSection(SolutionProperties) = preSolution 63 | HideSolutionNode = FALSE 64 | EndGlobalSection 65 | GlobalSection(ExtensibilityGlobals) = postSolution 66 | SolutionGuid = {98A9768C-D450-4125-8057-441B3C106F5E} 67 | EndGlobalSection 68 | EndGlobal 69 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Services/GistGithubUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace RevitAddin.CommandLoader.Services 6 | { 7 | public class GistGithubUtils 8 | { 9 | /// 10 | /// Try to download the content of a gist from a given url. 11 | /// 12 | /// 13 | /// 14 | /// 15 | public static bool TryGetGistString(string url, out string output) 16 | { 17 | output = ""; 18 | if (url.IndexOf("gist.github", StringComparison.InvariantCultureIgnoreCase) > -1) 19 | { 20 | url = url.Trim('/'); 21 | if (url.IndexOf("/raw", StringComparison.InvariantCultureIgnoreCase) == -1) 22 | { 23 | url += "/raw"; 24 | } 25 | output = GetString(url); 26 | return true; 27 | } 28 | return false; 29 | } 30 | 31 | /// 32 | /// Try to get Gist Id. 33 | /// 34 | /// 35 | /// 36 | /// 37 | public static bool TryGetGistId(string url, out string id) 38 | { 39 | id = ""; 40 | if (url.IndexOf("gist.github", StringComparison.InvariantCultureIgnoreCase) > -1) 41 | { 42 | url = url.Trim('/'); 43 | id = url.Split('/').Last(); 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | /// 50 | /// Try to get the content of a gist from a given url. 51 | /// 52 | /// 53 | /// 54 | /// 55 | public static bool TryGetGistFilesContent(string url, out string[] contents) 56 | { 57 | contents = null; 58 | if (TryGetGistModel(url, out GistModel gistModel)) 59 | { 60 | if (gistModel is not null) 61 | { 62 | contents = gistModel.files.Values.Select(e => e.content).ToArray(); 63 | return contents.Length > 0; 64 | } 65 | } 66 | return false; 67 | } 68 | 69 | public static bool TryGetGistModel(string url, out GistModel gistModel) 70 | { 71 | gistModel = null; 72 | if (TryGetGistId(url, out string gistId)) 73 | { 74 | var content = GetGistString(gistId); 75 | if (content is null) 76 | return false; 77 | 78 | try 79 | { 80 | var jsonService = new JsonService(); 81 | gistModel = jsonService.Deserialize(content); 82 | } 83 | catch (System.Exception ex) 84 | { 85 | Console.WriteLine(ex); 86 | } 87 | 88 | return gistModel is not null; 89 | } 90 | return false; 91 | } 92 | 93 | private static string GetGistString(string id) 94 | { 95 | try 96 | { 97 | return GetString($"https://api.github.com/gists/{id}"); 98 | } 99 | catch { } 100 | return null; 101 | } 102 | 103 | private static string GetString(string url) 104 | { 105 | using (var client = new System.Net.WebClient()) 106 | { 107 | client.Headers.Add(System.Net.HttpRequestHeader.UserAgent, typeof(GistGithubUtils).Assembly.GetName().Name); 108 | return client.DownloadString(url); 109 | } 110 | } 111 | } 112 | 113 | public class GistModel 114 | { 115 | public string Id { get; set; } 116 | public Dictionary files { set; get; } 117 | 118 | public class File 119 | { 120 | public double size { set; get; } 121 | public string filename { set; get; } 122 | public string raw_url { set; get; } 123 | public string language { set; get; } 124 | public string content { set; get; } 125 | } 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Revit/App.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.DB; 2 | using Autodesk.Revit.UI; 3 | using RevitAddin.CommandLoader.Extensions; 4 | using ricaun.Revit.Github; 5 | using ricaun.Revit.UI; 6 | using ricaun.Revit.UI.Drawing; 7 | using ricaun.Revit.UI.Tasks; 8 | using System; 9 | using System.ComponentModel; 10 | using System.Linq; 11 | using System.Reflection; 12 | using System.Threading.Tasks; 13 | 14 | namespace RevitAddin.CommandLoader.Revit 15 | { 16 | [AppLoader] 17 | public class App : IExternalApplication 18 | { 19 | private static GithubRequestService service; 20 | private static RibbonPanel ribbonPanel; 21 | private static RibbonPanel ribbonPanelAssembly; 22 | private static UIControlledApplication UIControlledApplication; 23 | 24 | private static RevitTaskService revitTaskService; 25 | public static IRevitTask RevitTask => revitTaskService; 26 | public Result OnStartup(UIControlledApplication application) 27 | { 28 | revitTaskService = new RevitTaskService(application); 29 | revitTaskService.Initialize(); 30 | 31 | UIControlledApplication = application; 32 | ribbonPanel = application.CreatePanel("CommandLoader"); 33 | ribbonPanel.CreatePushButton("Command\rLoader") 34 | .SetLargeImage(AppName.GetIcon()) 35 | .SetToolTip("Open CommandLoader window that compiles Revit code and creates pushbuttons for each `IExternalCommand`, `IExternalCommandAvailability` could be used in the same class to enable the availability features.") 36 | .SetLongDescription(AppName.GetInfo()) 37 | .SetContextualHelp(AppName.GetUri()); 38 | 39 | service = new GithubRequestService("ricaun-io", "RevitAddin.CommandLoader"); 40 | 41 | application.ControlledApplication.ApplicationInitialized += ControlledApplication_ApplicationInitialized; 42 | 43 | #if DEBUG 44 | ribbonPanel.GetRibbonPanel().CustomPanelTitleBarBackground = System.Windows.Media.Brushes.Salmon; 45 | #endif 46 | 47 | return Result.Succeeded; 48 | } 49 | public Result OnShutdown(UIControlledApplication application) 50 | { 51 | revitTaskService?.Dispose(); 52 | 53 | ribbonPanel?.Remove(); 54 | ribbonPanelAssembly?.Remove(); 55 | 56 | application.ControlledApplication.ApplicationInitialized -= ControlledApplication_ApplicationInitialized; 57 | return Result.Succeeded; 58 | } 59 | 60 | private void ControlledApplication_ApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e) 61 | { 62 | Task.Run(async () => 63 | { 64 | bool downloadedNewVersion = await service.Initialize(); 65 | if (downloadedNewVersion) 66 | { 67 | InfoCenterUtils.ShowBalloon("Download New Release!", null, AppName.GetUri()); 68 | Console.WriteLine($"RevitAddin.CommandLoader: {downloadedNewVersion}"); 69 | } 70 | }); 71 | } 72 | 73 | public static void CreateCommands(Assembly assembly) 74 | { 75 | if (ribbonPanelAssembly is not null) ribbonPanelAssembly?.Remove(); 76 | 77 | var commands = assembly.GetTypes().Where(e => typeof(IExternalCommand).IsAssignableFrom(e)); 78 | 79 | ribbonPanelAssembly = UIControlledApplication.CreatePanel(""); 80 | foreach (var command in commands) 81 | { 82 | var button = ribbonPanelAssembly 83 | .AddItem(ribbonPanel.NewPushButtonData(command)); 84 | 85 | if (command.TryGetAttribute(out DisplayNameAttribute displayNameAttribute)) 86 | { 87 | if (!string.IsNullOrEmpty(displayNameAttribute.DisplayName)) 88 | { 89 | button.SetText(displayNameAttribute.DisplayName); 90 | } 91 | } 92 | if (command.TryGetAttribute(out DescriptionAttribute descriptionAttribute)) 93 | { 94 | if (!string.IsNullOrEmpty(descriptionAttribute.Description)) 95 | { 96 | button.SetToolTip(descriptionAttribute.Description); 97 | } 98 | } 99 | 100 | var needImage = true; 101 | if (command.TryGetAttribute(out DesignerAttribute designerAttribute)) 102 | { 103 | if (!string.IsNullOrEmpty(designerAttribute.DesignerTypeName)) 104 | { 105 | button.SetLargeImage(designerAttribute.DesignerTypeName); 106 | needImage = false; 107 | } 108 | } 109 | 110 | if (needImage) 111 | { 112 | button.SetLargeImage(AutodeskIconGeneratorUtils.GetCube()); 113 | } 114 | } 115 | } 116 | 117 | } 118 | } -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/Revit/CodeSamples.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.NetworkInformation; 3 | using System.Security.Policy; 4 | 5 | namespace RevitAddin.CommandLoader.Revit 6 | { 7 | public class CodeSamples 8 | { 9 | public static string CommandThemeGist => "https://gist.github.com/ricaun/86334ff6560e3e8c4671148c5c995b39"; 10 | public static string CommandVersionGist => "https://gist.github.com/ricaun/200a576c3baa45cba034ceedac1e708e"; 11 | public static string Command => 12 | @"using System; 13 | using System.ComponentModel; 14 | using Autodesk.Revit.Attributes; 15 | using Autodesk.Revit.DB; 16 | using Autodesk.Revit.UI; 17 | 18 | namespace RevitAddin 19 | { 20 | [DisplayName(""Revit\rVersion"")] 21 | [Description(""Show a Window with the Revit VersionName."")] 22 | [Designer(""/UIFrameworkRes;component/ribbon/images/revit.ico"")] 23 | [Transaction(TransactionMode.Manual)] 24 | public class Command : IExternalCommand, IExternalCommandAvailability 25 | { 26 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 27 | { 28 | UIApplication uiapp = commandData.Application; 29 | System.Windows.MessageBox.Show(uiapp.Application.VersionName); 30 | return Result.Succeeded; 31 | } 32 | public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) 33 | { 34 | return true; 35 | } 36 | } 37 | }"; 38 | 39 | public static string CommandVersion => 40 | @"using System; 41 | using System.ComponentModel; 42 | using Autodesk.Revit.Attributes; 43 | using Autodesk.Revit.DB; 44 | using Autodesk.Revit.UI; 45 | 46 | namespace RevitAddin 47 | { 48 | [DisplayName(""Revit\rVersion"")] 49 | [Description(""Show a Window with the Revit VersionName."")] 50 | [Designer(""/UIFrameworkRes;component/ribbon/images/revit.ico"")] 51 | [Transaction(TransactionMode.Manual)] 52 | public class CommandVersion : IExternalCommand, IExternalCommandAvailability 53 | { 54 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 55 | { 56 | UIApplication uiapp = commandData.Application; 57 | System.Windows.MessageBox.Show(uiapp.Application.VersionName); 58 | return Result.Succeeded; 59 | } 60 | public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) 61 | { 62 | return true; 63 | } 64 | } 65 | }"; 66 | 67 | public static string CommandDeleteWalls => 68 | @"using System; 69 | using System.Collections.Generic; 70 | using System.Linq; 71 | using System.ComponentModel; 72 | using Autodesk.Revit.ApplicationServices; 73 | using Autodesk.Revit.Attributes; 74 | using Autodesk.Revit.DB; 75 | using Autodesk.Revit.UI; 76 | 77 | namespace RevitAddin 78 | { 79 | [Transaction(TransactionMode.Manual)] 80 | public class DeleteWalls : IExternalCommand 81 | { 82 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 83 | { 84 | UIApplication uiapp = commandData.Application; 85 | UIDocument uidoc = uiapp.ActiveUIDocument; 86 | Application app = uiapp.Application; 87 | Document doc = uidoc.Document; 88 | 89 | // Get all walls in the document 90 | List walls = new FilteredElementCollector(doc) 91 | .OfClass(typeof(Wall)) 92 | .Cast() 93 | .ToList(); 94 | 95 | // Delete all walls 96 | using (Transaction trans = new Transaction(doc)) 97 | { 98 | trans.Start(""Delete Walls""); 99 | foreach (Wall wall in walls) 100 | { 101 | doc.Delete(wall.Id); 102 | } 103 | trans.Commit(); 104 | } 105 | return Result.Succeeded; 106 | } 107 | } 108 | }"; 109 | 110 | public static string CommandTask => 111 | @"using System; 112 | using System.ComponentModel; 113 | using System.Threading.Tasks; 114 | using Autodesk.Revit.Attributes; 115 | using Autodesk.Revit.DB; 116 | using Autodesk.Revit.UI; 117 | 118 | namespace RevitAddin 119 | { 120 | [DisplayName(""Task"")] 121 | [Designer(""/UIFrameworkRes;component/ribbon/images/revit.ico"")] 122 | [Transaction(TransactionMode.Manual)] 123 | public class CommandTask : IExternalCommand, IExternalCommandAvailability 124 | { 125 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 126 | { 127 | UIApplication uiapp = commandData.Application; 128 | 129 | Task.Run(async () => 130 | { 131 | await Task.Delay(100); 132 | System.Windows.MessageBox.Show(uiapp.Application.VersionName); 133 | }); 134 | 135 | return Result.Succeeded; 136 | } 137 | public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) 138 | { 139 | return true; 140 | } 141 | } 142 | }"; 143 | } 144 | } 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RevitAddin.CommandLoader 2 | 3 | [![Revit 2017](https://img.shields.io/badge/Revit-2017+-blue.svg)](../..) 4 | [![Visual Studio 2022](https://img.shields.io/badge/Visual%20Studio-2022-blue)](../..) 5 | [![Nuke](https://img.shields.io/badge/Nuke-Build-blue)](https://nuke.build/) 6 | [![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) 7 | [![Build](../../actions/workflows/Build.yml/badge.svg)](../../actions) 8 | 9 | ![CommandLoader](https://github.com/ricaun-io/RevitAddin.CommandLoader/assets/12437519/f54aadb6-5df7-4586-ad08-d4b9e85524d7) 10 | 11 | `RevitAddin.CommandLoader` project compiles `IExternalCommand` with Revit open using `CodeDom.Compiler` and creates a `PushButton` on the Revit ribbon. 12 | 13 | This project was generated by the [AppLoader](https://ricaun.com/apploader/) Revit plugin. 14 | 15 | ## Features 16 | 17 | * Compile multiple `IExternalCommand` at once with Revit opened. 18 | * Generate `PushButton` with the compiled `IExternalCommand` with `IExternalCommandAvailability`. 19 | * AutoUpdate plugin using [ricaun.Revit.Github](https://github.com/ricaun-io/ricaun.Revit.Github). 20 | * `Gist` link downloads the content and compiles each file. 21 | 22 | ## Compiler Limitations 23 | 24 | Revit 2017 to 2020 the `CodeDom.Compiler` only work with C# compiler version `v4.0` maximum, the following features do not work in C# version 4. 25 | * Async Features (C# version 5) 26 | * String interpolation (C# version 6) 27 | 28 | Revit 2021 to 2024 the `CodeDom.Compiler` uses the [Roslyn](https://github.com/aspnet/RoslynCodeDomProvider) version compiler. The Roslyn compiler is a new compiler that supports C# version 6 and above. 29 | 30 | Revit 2025+ the `CodeDom.Compiler` uses the [Microsoft.CodeAnalysis.CSharp](https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp/) to work with NET Core. 31 | 32 | The [RevitAddin.CommandLoader.Tests](RevitAddin.CommandLoader.Tests) have some tests to make sure the compiler works in Net Framework and Net Core. 33 | 34 | ## Customize `IExternalCommand` 35 | 36 | Using `System.ComponentModel` attributes is possible to customize the `IExternalCommand` that is generated in the Revit ribbon. 37 | 38 | * `DisplayNameAttribute`: Set the Text in the `PushButton`. 39 | * `DescriptionAttribute`: Set the Tooltip in the `PushButton`. 40 | * `DesignerAttribute`: Set the LargeImage in the `PushButton`. (Works with `component`, `URL`, and `base64`) 41 | 42 | If `IExternalCommandAvailability` is added in the same `IExternalCommand` class the availability gonna be applied in the `PushButton`. 43 | 44 | ### Example 45 | 46 | The command below show the version of Revit in a `MessageBox`. 47 | 48 | ```c# 49 | using System; 50 | using System.ComponentModel; 51 | using Autodesk.Revit.Attributes; 52 | using Autodesk.Revit.DB; 53 | using Autodesk.Revit.UI; 54 | 55 | namespace RevitAddin 56 | { 57 | [DisplayName("Revit\rVersion")] 58 | [Description("Show a Window with the Revit VersionName.")] 59 | [Designer("/UIFrameworkRes;component/ribbon/images/revit.ico")] 60 | [Transaction(TransactionMode.Manual)] 61 | public class Command : IExternalCommand, IExternalCommandAvailability 62 | { 63 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) 64 | { 65 | UIApplication uiapp = commandData.Application; 66 | System.Windows.MessageBox.Show(uiapp.Application.VersionName); 67 | return Result.Succeeded; 68 | } 69 | public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) 70 | { 71 | return true; 72 | } 73 | } 74 | } 75 | ``` 76 | 77 | ### Gist Example 78 | 79 | The `RevitAddin.CommandLoader` have the feature to download `gist` files from GitHub and compile the `IExternalCommand` with the `gist` file. 80 | 81 | Just copy the `gist` link in the `RevitAddin.CommandLoader` compiler and execute. 82 | 83 | * [CommandVersion](https://gist.github.com/ricaun/200a576c3baa45cba034ceedac1e708e) - File with Revit defines. 84 | * [CommandCreate](https://gist.github.com/ricaun/4f62b8650d29f1ff837e7e77f9e8b552) - Multiple file each with a `IExternalCommand`. 85 | * [CommandTheme](https://gist.github.com/ricaun/86334ff6560e3e8c4671148c5c995b39) - Commands to change `UITheme`. 86 | 87 | ## Resources 88 | 89 | * [ricaun.Revit.UI](https://github.com/ricaun-io/ricaun.Revit.UI) 90 | * [ricaun.Revit.Mvvm](https://github.com/ricaun-io/ricaun.Revit.Mvvm) 91 | * [ricaun.Revit.Github](https://github.com/ricaun-io/ricaun.Revit.Github) 92 | * [ricaun.Revit.UI.Tasks](https://github.com/ricaun-io/ricaun.Revit.UI.Tasks) 93 | 94 | ## Installation 95 | 96 | * Download and install [RevitAddin.CommandLoader.exe](../../releases/latest/download/RevitAddin.CommandLoader.zip) 97 | 98 | ## Video 99 | 100 | Videos in Portuguese with the creation of this project. 101 | 102 | [![VideoIma1]][Video1] 103 | 104 | Videos in English about this project. 105 | 106 | [![VideoIma2]][Video2] [![VideoIma3]][Video3] [![VideoIma4]][Video4] 107 | 108 | ## License 109 | 110 | This project is [licensed](LICENSE) under the [MIT License](https://en.wikipedia.org/wiki/MIT_License). 111 | 112 | --- 113 | 114 | Do you like this project? Please [star this project on GitHub](../../stargazers)! 115 | 116 | [Video1]: https://youtu.be/4oVJWDRhrRs 117 | [VideoIma1]: https://img.youtube.com/vi/4oVJWDRhrRs/mqdefault.jpg 118 | 119 | [Video2]: https://youtu.be/hI21lxm4EVU 120 | [VideoIma2]: https://img.youtube.com/vi/hI21lxm4EVU/mqdefault.jpg 121 | [Video3]: https://youtu.be/cOu7vjZnyXc 122 | [VideoIma3]: https://img.youtube.com/vi/cOu7vjZnyXc/mqdefault.jpg 123 | [Video4]: https://youtu.be/y2GkFXoFwow 124 | [VideoIma4]: https://img.youtube.com/vi/y2GkFXoFwow/mqdefault.jpg 125 | -------------------------------------------------------------------------------- /RevitAddin.CommandLoader/RevitAddin.CommandLoader.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Library 6 | AnyCPU 7 | true 8 | latest 9 | false 10 | None 11 | Debug 2017;2017;Debug 2021;2021;2025;Debug 2025 12 | 13 | 14 | 15 | 16 | 17 | 18 | 2017 19 | net46 20 | 21 | 22 | 23 | 24 | 2018 25 | net46 26 | 27 | 28 | 29 | 30 | 2019 31 | net47 32 | 33 | 34 | 35 | 36 | 2020 37 | net47 38 | 39 | 40 | 41 | 42 | 2021 43 | net48 44 | 45 | 46 | 47 | 48 | 2022 49 | net48 50 | 51 | 52 | 53 | 54 | 2023 55 | net48 56 | 57 | 58 | 59 | 60 | 2024 61 | net48 62 | 63 | 64 | 65 | 66 | 2025 67 | net8.0-windows 68 | 69 | 70 | 71 | 72 | 2017 73 | net46 74 | 75 | 76 | 77 | 78 | 79 | 80 | true 81 | true 82 | false 83 | 84 | 85 | 86 | 87 | true 88 | bin\Release\$(RevitVersion)\ 89 | REVIT$(RevitVersion) 90 | MSB3052 91 | None 92 | 93 | 94 | 95 | 96 | true 97 | bin\Debug\ 98 | DEBUG;TRACE;REVIT$(RevitVersion) 99 | Full 100 | 101 | 102 | 103 | 104 | $(RevitVersion) 105 | Program 106 | C:\Program Files\Autodesk\Revit $(DebugRevitVersion)\Revit.exe 107 | 108 | 109 | 110 | RevitAddin.CommandLoader 111 | {82070359-36DA-4441-A59D-9018B6A8B348} 112 | 113 | 114 | 115 | 116 | 117 | 118 | false 119 | $([MSBuild]::Divide($([System.DateTime]::Now.TimeOfDay.TotalSeconds), 4).ToString('F0')) 120 | .Dev.$(Version).$(Revision) 121 | 122 | 123 | 124 | ricaun 125 | Luiz Henrique Cassettari 126 | Revit Plugin Description for $(PackageId). 127 | $([System.DateTime]::Now.ToString('yyyy')) 128 | 129 | 130 | 131 | $(PackageId)$(PackageAssemblyVersion) 132 | $(PackageId) 133 | Copyright © $(CopyrightYears) $(Company) 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | NU1903 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Build/.nuke/build.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "definitions": { 4 | "Host": { 5 | "type": "string", 6 | "enum": [ 7 | "AppVeyor", 8 | "AzurePipelines", 9 | "Bamboo", 10 | "Bitbucket", 11 | "Bitrise", 12 | "GitHubActions", 13 | "GitLab", 14 | "Jenkins", 15 | "Rider", 16 | "SpaceAutomation", 17 | "TeamCity", 18 | "Terminal", 19 | "TravisCI", 20 | "VisualStudio", 21 | "VSCode" 22 | ] 23 | }, 24 | "IssConfiguration": { 25 | "type": "object", 26 | "description": "IssConfiguration", 27 | "properties": { 28 | "Title": { 29 | "type": [ 30 | "null", 31 | "string" 32 | ], 33 | "description": "Title (default null)" 34 | }, 35 | "Image": { 36 | "type": [ 37 | "null", 38 | "string" 39 | ], 40 | "description": "Image (default IMAGE)" 41 | }, 42 | "ImageSmall": { 43 | "type": [ 44 | "null", 45 | "string" 46 | ], 47 | "description": "Small Image (default IMAGESMALL)" 48 | }, 49 | "Icon": { 50 | "type": [ 51 | "null", 52 | "string" 53 | ], 54 | "description": "Icon (default ICON)" 55 | }, 56 | "Licence": { 57 | "type": [ 58 | "null", 59 | "string" 60 | ], 61 | "description": "Licence (default LICENSE)" 62 | }, 63 | "Language": { 64 | "description": "Language (default IssLanguage)", 65 | "oneOf": [ 66 | { 67 | "type": "null" 68 | }, 69 | { 70 | "$ref": "#/definitions/IssLanguage" 71 | } 72 | ] 73 | }, 74 | "IssLanguageLicences": { 75 | "type": [ 76 | "array", 77 | "null" 78 | ], 79 | "description": "IssLanguages", 80 | "items": { 81 | "$ref": "#/definitions/IssLanguageLicence" 82 | } 83 | } 84 | } 85 | }, 86 | "IssLanguage": { 87 | "type": "object", 88 | "description": "IssLanguage", 89 | "properties": { 90 | "Name": { 91 | "type": [ 92 | "null", 93 | "string" 94 | ], 95 | "description": "Name (default \"en\")" 96 | }, 97 | "MessagesFile": { 98 | "type": [ 99 | "null", 100 | "string" 101 | ], 102 | "description": "MessagesFile (default \"compiler:Default.isl\")" 103 | } 104 | } 105 | }, 106 | "IssLanguageLicence": { 107 | "type": "object", 108 | "description": "IssLanguageLicence", 109 | "properties": { 110 | "Name": { 111 | "type": [ 112 | "null", 113 | "string" 114 | ], 115 | "description": "Name (default \"en\")" 116 | }, 117 | "MessagesFile": { 118 | "type": [ 119 | "null", 120 | "string" 121 | ], 122 | "description": "MessagesFile (default \"compiler:Default.isl\")" 123 | }, 124 | "Licence": { 125 | "type": [ 126 | "null", 127 | "string" 128 | ], 129 | "description": "Licence (default LICENSE)" 130 | } 131 | } 132 | }, 133 | "ExecutableTarget": { 134 | "type": "string", 135 | "enum": [ 136 | "Build", 137 | "Clean", 138 | "Compile", 139 | "GitPreRelease", 140 | "GitRelease", 141 | "PackageBuilder", 142 | "Release", 143 | "Sign", 144 | "Test" 145 | ] 146 | }, 147 | "Verbosity": { 148 | "type": "string", 149 | "description": "", 150 | "enum": [ 151 | "Verbose", 152 | "Normal", 153 | "Minimal", 154 | "Quiet" 155 | ] 156 | }, 157 | "NukeBuild": { 158 | "properties": { 159 | "Continue": { 160 | "type": "boolean", 161 | "description": "Indicates to continue a previously failed build attempt" 162 | }, 163 | "Help": { 164 | "type": "boolean", 165 | "description": "Shows the help text for this build assembly" 166 | }, 167 | "Host": { 168 | "description": "Host for execution. Default is 'automatic'", 169 | "$ref": "#/definitions/Host" 170 | }, 171 | "NoLogo": { 172 | "type": "boolean", 173 | "description": "Disables displaying the NUKE logo" 174 | }, 175 | "Partition": { 176 | "type": "string", 177 | "description": "Partition to use on CI" 178 | }, 179 | "Plan": { 180 | "type": "boolean", 181 | "description": "Shows the execution plan (HTML)" 182 | }, 183 | "Profile": { 184 | "type": "array", 185 | "description": "Defines the profiles to load", 186 | "items": { 187 | "type": "string" 188 | } 189 | }, 190 | "Root": { 191 | "type": "string", 192 | "description": "Root directory during build execution" 193 | }, 194 | "Skip": { 195 | "type": "array", 196 | "description": "List of targets to be skipped. Empty list skips all dependencies", 197 | "items": { 198 | "$ref": "#/definitions/ExecutableTarget" 199 | } 200 | }, 201 | "Target": { 202 | "type": "array", 203 | "description": "List of targets to be invoked. Default is '{default_target}'", 204 | "items": { 205 | "$ref": "#/definitions/ExecutableTarget" 206 | } 207 | }, 208 | "Verbosity": { 209 | "description": "Logging verbosity during build execution. Default is 'Normal'", 210 | "$ref": "#/definitions/Verbosity" 211 | } 212 | } 213 | } 214 | }, 215 | "allOf": [ 216 | { 217 | "properties": { 218 | "ApplicationType": { 219 | "type": "string" 220 | }, 221 | "EnableForkedRepository": { 222 | "type": "boolean" 223 | }, 224 | "Folder": { 225 | "type": "string" 226 | }, 227 | "GitHubToken": { 228 | "type": "string", 229 | "default": "Secrets must be entered via 'nuke :secrets [profile]'" 230 | }, 231 | "InstallationFiles": { 232 | "type": "string" 233 | }, 234 | "IssConfiguration": { 235 | "$ref": "#/definitions/IssConfiguration" 236 | }, 237 | "MainName": { 238 | "type": "string" 239 | }, 240 | "MiddleVersions": { 241 | "type": "boolean" 242 | }, 243 | "Name": { 244 | "type": "string" 245 | }, 246 | "NewVersions": { 247 | "type": "boolean" 248 | }, 249 | "PreReleaseFilter": { 250 | "type": "array", 251 | "items": { 252 | "type": "string" 253 | } 254 | }, 255 | "ProjectNameFolder": { 256 | "type": "boolean" 257 | }, 258 | "ProjectRemoveTargetFrameworkFolder": { 259 | "type": "boolean" 260 | }, 261 | "ProjectVersionFolder": { 262 | "type": "boolean" 263 | }, 264 | "ReleaseBundle": { 265 | "type": "boolean" 266 | }, 267 | "ReleaseFolder": { 268 | "type": "string" 269 | }, 270 | "ReleaseNameVersion": { 271 | "type": "boolean" 272 | }, 273 | "ReleasePackageBuilder": { 274 | "type": "boolean" 275 | }, 276 | "SignFile": { 277 | "type": "string", 278 | "default": "Secrets must be entered via 'nuke :secrets [profile]'" 279 | }, 280 | "SignPassword": { 281 | "type": "string", 282 | "default": "Secrets must be entered via 'nuke :secrets [profile]'" 283 | }, 284 | "Solution": { 285 | "type": "string", 286 | "description": "Path to a solution file that is automatically loaded" 287 | }, 288 | "TestBuildStopWhenFailed": { 289 | "type": "boolean" 290 | }, 291 | "TestProjectName": { 292 | "type": "string" 293 | }, 294 | "TestResults": { 295 | "type": "boolean" 296 | }, 297 | "VendorDescription": { 298 | "type": "string" 299 | }, 300 | "VendorId": { 301 | "type": "string" 302 | } 303 | } 304 | }, 305 | { 306 | "$ref": "#/definitions/NukeBuild" 307 | } 308 | ] 309 | } 310 | --------------------------------------------------------------------------------