diff --git a/Build/.nuke/build.schema.json b/Build/.nuke/build.schema.json index a9a6bbc..6472f2a 100644 --- a/Build/.nuke/build.schema.json +++ b/Build/.nuke/build.schema.json @@ -1,52 +1,237 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "$ref": "#/definitions/build", - "title": "Build Schema", "definitions": { - "build": { + "Host": { + "type": "string", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "IssConfiguration": { "type": "object", + "description": "IssConfiguration", + "properties": { + "Title": { + "type": [ + "null", + "string" + ], + "description": "Title (default null)" + }, + "Image": { + "type": [ + "null", + "string" + ], + "description": "Image (default IMAGE)" + }, + "ImageSmall": { + "type": [ + "null", + "string" + ], + "description": "Small Image (default IMAGESMALL)" + }, + "Icon": { + "type": [ + "null", + "string" + ], + "description": "Icon (default ICON)" + }, + "Licence": { + "type": [ + "null", + "string" + ], + "description": "Licence (default LICENSE)" + }, + "Language": { + "description": "Language (default IssLanguage)", + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/IssLanguage" + } + ] + }, + "IssLanguageLicences": { + "type": [ + "array", + "null" + ], + "description": "IssLanguages", + "items": { + "$ref": "#/definitions/IssLanguageLicence" + } + } + } + }, + "IssLanguage": { + "type": "object", + "description": "IssLanguage", + "properties": { + "Name": { + "type": [ + "null", + "string" + ], + "description": "Name (default \"en\")" + }, + "MessagesFile": { + "type": [ + "null", + "string" + ], + "description": "MessagesFile (default \"compiler:Default.isl\")" + } + } + }, + "IssLanguageLicence": { + "type": "object", + "description": "IssLanguageLicence", + "properties": { + "Name": { + "type": [ + "null", + "string" + ], + "description": "Name (default \"en\")" + }, + "MessagesFile": { + "type": [ + "null", + "string" + ], + "description": "MessagesFile (default \"compiler:Default.isl\")" + }, + "Licence": { + "type": [ + "null", + "string" + ], + "description": "Licence (default LICENSE)" + } + } + }, + "ExecutableTarget": { + "type": "string", + "enum": [ + "Build", + "BuildConsole", + "Clean", + "Compile", + "GitPreRelease", + "GitRelease", + "Pack", + "PackageBuilder", + "PrePack", + "Release", + "Sign" + ] + }, + "Verbosity": { + "type": "string", + "description": "", + "enum": [ + "Verbose", + "Normal", + "Minimal", + "Quiet" + ] + }, + "NukeBuild": { "properties": { "Continue": { "type": "boolean", "description": "Indicates to continue a previously failed build attempt" }, - "Folder": { - "type": "string" - }, - "GitHubToken": { - "type": "string", - "default": "Secrets must be entered via 'nuke :secrets [profile]'" - }, "Help": { "type": "boolean", "description": "Shows the help text for this build assembly" }, "Host": { - "type": "string", "description": "Host for execution. Default is 'automatic'", - "enum": [ - "AppVeyor", - "AzurePipelines", - "Bamboo", - "Bitbucket", - "Bitrise", - "GitHubActions", - "GitLab", - "Jenkins", - "Rider", - "SpaceAutomation", - "TeamCity", - "Terminal", - "TravisCI", - "VisualStudio", - "VSCode" - ] + "$ref": "#/definitions/Host" + }, + "NoLogo": { + "type": "boolean", + "description": "Disables displaying the NUKE logo" + }, + "Partition": { + "type": "string", + "description": "Partition to use on CI" + }, + "Plan": { + "type": "boolean", + "description": "Shows the execution plan (HTML)" + }, + "Profile": { + "type": "array", + "description": "Defines the profiles to load", + "items": { + "type": "string" + } + }, + "Root": { + "type": "string", + "description": "Root directory during build execution" + }, + "Skip": { + "type": "array", + "description": "List of targets to be skipped. Empty list skips all dependencies", + "items": { + "$ref": "#/definitions/ExecutableTarget" + } + }, + "Target": { + "type": "array", + "description": "List of targets to be invoked. Default is '{default_target}'", + "items": { + "$ref": "#/definitions/ExecutableTarget" + } + }, + "Verbosity": { + "description": "Logging verbosity during build execution. Default is 'Normal'", + "$ref": "#/definitions/Verbosity" + } + } + } + }, + "allOf": [ + { + "properties": { + "EnableForkedRepository": { + "type": "boolean" + }, + "Folder": { + "type": "string" + }, + "GitHubToken": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, "InstallationFiles": { "type": "string" }, "IssConfiguration": { - "type": "string" + "$ref": "#/definitions/IssConfiguration" }, "MainName": { "type": "string" @@ -60,10 +245,6 @@ "NewVersions": { "type": "boolean" }, - "NoLogo": { - "type": "boolean", - "description": "Disables displaying the NUKE logo" - }, "NugetApiKey": { "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" @@ -72,27 +253,12 @@ "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, - "Partition": { - "type": "string", - "description": "Partition to use on CI" - }, - "Plan": { - "type": "boolean", - "description": "Shows the execution plan (HTML)" - }, "PreReleaseFilter": { "type": "array", "items": { "type": "string" } }, - "Profile": { - "type": "array", - "description": "Defines the profiles to load", - "items": { - "type": "string" - } - }, "ProjectNameFolder": { "type": "boolean" }, @@ -117,10 +283,6 @@ "ReleasePackageBuilder": { "type": "boolean" }, - "Root": { - "type": "string", - "description": "Root directory during build execution" - }, "SignFile": { "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" @@ -129,50 +291,10 @@ "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, - "Skip": { - "type": "array", - "description": "List of targets to be skipped. Empty list skips all dependencies", - "items": { - "type": "string", - "enum": [ - "Build", - "BuildConsole", - "Clean", - "Compile", - "GitPreRelease", - "GitRelease", - "Pack", - "PackageBuilder", - "PrePack", - "Release", - "Sign" - ] - } - }, "Solution": { "type": "string", "description": "Path to a solution file that is automatically loaded" }, - "Target": { - "type": "array", - "description": "List of targets to be invoked. Default is '{default_target}'", - "items": { - "type": "string", - "enum": [ - "Build", - "BuildConsole", - "Clean", - "Compile", - "GitPreRelease", - "GitRelease", - "Pack", - "PackageBuilder", - "PrePack", - "Release", - "Sign" - ] - } - }, "UnlistNuget": { "type": "boolean" }, @@ -181,18 +303,11 @@ }, "VendorId": { "type": "string" - }, - "Verbosity": { - "type": "string", - "description": "Logging verbosity during build execution. Default is 'Normal'", - "enum": [ - "Minimal", - "Normal", - "Quiet", - "Verbose" - ] } } + }, + { + "$ref": "#/definitions/NukeBuild" } - } + ] } diff --git a/Build/IBuildConsole.cs b/Build/IBuildConsole.cs index c0b5b6d..fba3b57 100644 --- a/Build/IBuildConsole.cs +++ b/Build/IBuildConsole.cs @@ -19,7 +19,7 @@ public interface IBuildConsole : IHazExample, IRevitPackageBuilder { var resourcesDirectory = project.Directory / "Bundle"; Serilog.Log.Information($"Copy Bundle: {file} to {resourcesDirectory}"); - FileSystemTasks.CopyFileToDirectory(file, resourcesDirectory, FileExistsPolicy.OverwriteIfNewer); + AbsolutePathExtensions.CopyToDirectory(file, resourcesDirectory, ExistsPolicy.FileOverwriteIfNewer); }); Solution.BuildProject(project, (project) => diff --git a/CHANGELOG.md b/CHANGELOG.md index 6590fd7..3e58acf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [1.4.1] / 2025-09-18 +## [1.4.2] / 2025-01-16 +### Features +- Add `ApplicationExtensions` to check `InAddInContext` and `InEventContext`. +- Add `DocumentCreated` event to confirm `ActiveAddInId` is null inside event. +### Updates +- Update `Build` copy. + +## [1.4.1] / 2024-09-18 ### Features - Create `Revit.DesignApplication` with `DesignApplication` to load correct assembly version in the bundle. (#7) ### Updates - Use `DesignApplication` to load correct assembly version in the bundle. - Add `ApplicationInitialized` event to test. -## [1.4.0] / 2025-08-27 +## [1.4.0] / 2024-08-27 ### Features - Support Bundle multiple versions of Revit using `DesignAutomationLoadVersion`. (#7) ### Updates @@ -21,11 +28,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Use `where T : IDesignAutomation` in `DesignAutomation` and `DesignAutomationLoadVersion`. - Fix `DesignAutomation` method selection by finding first method `Execute` with 3 parameters. -## [1.3.1] / 2025-06-15 - 2025-08-27 +## [1.3.1] / 2024-06-15 - 2024-08-27 - Add `AddInId` in the output. #9 - Update `AddInId` to `AddInName` in model class. -## [1.3.0] / 2025-04-05 +## [1.3.0] / 2024-04-05 - Update to Revit 2025 - Build `DesignAutomationConsole`. - Add `FrameworkName` and `Reference` in the output. @@ -47,6 +54,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - First Release [vNext]: ../../compare/1.0.0...HEAD +[1.4.2]: ../../compare/1.4.1...1.4.2 [1.4.1]: ../../compare/1.4.0...1.4.1 [1.4.0]: ../../compare/1.3.1...1.4.0 [1.3.1]: ../../compare/1.3.0...1.3.1 diff --git a/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip b/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip index 049c058..9708d06 100644 Binary files a/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip and b/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip differ diff --git a/Directory.Build.props b/Directory.Build.props index a5caae5..7fffec1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 1.4.1 + 1.4.2 \ No newline at end of file diff --git a/RevitAddin.DA.Tester/Services/ApplicationExtensions.cs b/RevitAddin.DA.Tester/Services/ApplicationExtensions.cs new file mode 100644 index 0000000..6532612 --- /dev/null +++ b/RevitAddin.DA.Tester/Services/ApplicationExtensions.cs @@ -0,0 +1,24 @@ +namespace RevitAddin.DA.Tester.Services +{ + public static class ApplicationExtensions + { + public static bool InAddInContext(this Autodesk.Revit.ApplicationServices.Application application) + { + return application.ActiveAddInId is not null; + } + + public static bool InEventContext(this Autodesk.Revit.ApplicationServices.Application application) + { + void Application_ProgressChanged(object sender, Autodesk.Revit.DB.Events.ProgressChangedEventArgs e) { } + try + { + application.ProgressChanged += Application_ProgressChanged; + application.ProgressChanged -= Application_ProgressChanged; + return true; + } + catch { } + return false; + } + + } +} \ No newline at end of file diff --git a/RevitAddin.DA.Tester/Services/DesignAutomationController.cs b/RevitAddin.DA.Tester/Services/DesignAutomationController.cs index cb66a9c..edfa6ea 100644 --- a/RevitAddin.DA.Tester/Services/DesignAutomationController.cs +++ b/RevitAddin.DA.Tester/Services/DesignAutomationController.cs @@ -41,10 +41,21 @@ public bool Execute(Application application, string filePath = null, Document do Console.WriteLine($"UI:\t{UI.IsValid()}"); Console.WriteLine($"App.AddInName:\t{App.AddInName}"); Console.WriteLine("----------------------------------------"); + Console.WriteLine($"InAddInContext:\t{application.InAddInContext()}"); + Console.WriteLine($"InEventContext:\t{application.InEventContext()}"); + Console.WriteLine("----------------------------------------"); Console.WriteLine($"Shape:\t{typeof(ricaun.Revit.DB.Shape.Colors).Assembly}"); Console.WriteLine($"Shape Location:\t{typeof(ricaun.Revit.DB.Shape.Colors).Assembly.Location}"); Console.WriteLine("----------------------------------------"); + application.DocumentCreated += (s, e) => { + Console.WriteLine($"DocumentCreated:\t{e.Document.Title}"); + Console.WriteLine($"DocumentCreated.AddInName: \t{application.ActiveAddInId?.GetAddInName()}"); + Console.WriteLine("----------------------------------------"); + }; + + application.NewProjectDocument(UnitSystem.Metric); + return true; } }