Repository navigation
6.3.0
Logging moves to Microsoft.Extensions.Logging, the code shared by an application and its modules moves to the new service defaults template, and the installer builds from a manifest.
In existing projects, update the SDK version and follow the migration guide.
Templates
Microsoft.Extensions.Logging
Add-ins log through Microsoft.Extensions.Logging with source-generated LoggerMessage methods. The Serilog packages are no longer referenced.
The logging option is available when dependency injection is enabled, and one call registers the providers:
builder.AddLoggingDefaults();public sealed partial class ProjectService(ILogger<ProjectService> logger)
{
public void Save(Document document)
{
document.Save();
LogProjectSaved(logger, document.Title);
}
[LoggerMessage(LogLevel.Information, "The project {Title} is saved.")]
private static partial void LogProjectSaved(ILogger<ProjectService> logger, string title);
}- Records with the
Errorlevel and above are written to the Revit journal through theNice3point.Revit.Loggingprovider. With hosting, theLogging:RevitJournal:LogLevelconfiguration section changes the level. - Unhandled
AppDomainexceptions are written to the log with theCriticallevel. - The
Configurationfolder is replaced byLoggingandDiagnostics.
Service defaults template
The new revit-servicedefaults template creates a project for the service configuration that an application and its modules share, on the model of the .NET Aspire service defaults.
The template provides logging and diagnostics, and the project is the place for every other shared registration: serialization, HTTP clients, options.
revit-addin-application now creates the entry point alone, and the application host applies the shared defaults with one call:
dotnet new revit-addin-application -n RevitAddIn --di hosting
dotnet new revit-servicedefaults -n RevitAddIn.ServiceDefaultsbuilder.AddServiceDefaults();Installer
The installer project moved from the install folder to installer and builds the MSI packages from a manifest that the build writes.
-
The
.addinmanifests are installed after the assemblies they reference. An interrupted installation no longer registers an add-in whose assemblies are missing. -
The upgrade code is configured in the
Installersection ofbuild/appsettings.json:"Installer": { "UpgradeCode": "CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC" }
-
The product name of the packages comes from the add-in project.
-
The packages no longer contain
.pdbfiles.
Tests and benchmarks
- The test project is adapted to the latest
Nice3point.TUnit.Revit, which runs test hooks on the Revit thread.[HookExecutor<RevitThreadExecutor>]andTestsConfiguration.csare removed. - The test template contains a TUnit assertion.
- The benchmark project runs through
BenchmarkSwitcher. Command-line arguments select the benchmarks to run:dotnet run -c Release.R26 -- --filter '*'. - The benchmark class is marked
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)], and the IDE no longer reports the benchmarks as unused.
Generated code
- Entry points, views, view models, host services, and build options have XML documentation.
- The solution contains the code style in
.editorconfigand the LF line-ending policy in.gitattributes. - Generated files use LF line endings, end with a newline, and follow the code style of the solution.
- The solution pins the .NET SDK to the 10.0.1xx feature band.
- The
Modelsfolder is no longer created. - The host of an add-in sets
IHostEnvironment.ApplicationNameto the project name. - ILRepack, Polyfill, and
JetBrains.Annotationsare private assets of the generated projects.
Build
- Every options type declares its configuration section in
ConfigurationSectionName, andProgram.csbinds the options through it. - Build modules log through source-generated
LoggerMessagemethods. - Build and installer errors state the problem, the cause, and the action that resolves it:
Cannot create the bundle. No publish output was found in 'source/RevitAddIn/bin'. Set 'PublishAddin' to 'true' in the add-in project. - A solution without a bundle and an installer compiles
BuildOptions. - A version with a hyphen in the prerelease label keeps the whole label in
VersionSuffix. - The release of
1.0.0no longer takes the release notes from the1.0.0-rc.1entry of the changelog. - Release assets are uploaded as
application/octet-stream, and the asset files are closed after the upload. - The installer step removes the temporary WiX toolset after the build.
- The
teststep no longer disables ILRepack.
Samples
- The sample solution keeps logging, diagnostics, and serialization in a
ServiceDefaultsproject, and serializes through a source-generated context. - The Extensible Storage sample stores its data through a schema definition and a typed context.
Dependencies
- Updated dependencies.
SDK
- ILRepack merges the published add-in. The
bindirectory keeps the original assemblies for the projects that reference the add-in, such as a test project. - Repacking runs only when
PublishAddinorDeployAddinis enabled. - Updated dependencies.
Breaking changes
- Serilog is replaced by
Microsoft.Extensions.Logging. revit-addin-applicationno longer has the logging option. Logging comes from arevit-servicedefaultsproject.- The installer project moved from
installtoinstaller, and the upgrade code moved tobuild/appsettings.json. - Test hooks no longer use
RevitThreadExecutor. - Repacking requires
PublishAddinorDeployAddin.
Migration guide
Add-in
-
Delete the
Configurationfolder from the add-in project. -
Create a temporary project with version 6.3.0 and the same options, and copy the
LoggingandDiagnosticsfolders to the add-in project. -
Replace the Serilog registration in
Host.cs:// Before, hosting builder.Logging.ClearProviders(); builder.Logging.AddSerilog(); builder.ConfigureHosting(); // After, hosting builder.AddLoggingDefaults(); // Before, container services.AddSerilog(); _serviceProvider = services.BuildServiceProvider(); // After, container services.AddLoggingDefaults(); _serviceProvider = services.BuildServiceProvider(); _serviceProvider.GetRequiredService<AppDomainExceptionsHandler>().LogExceptions();
-
Remove the
Serilog,Serilog.Sinks.Debug, andSerilog.Extensions.Hostingpackage references. -
With hosting, Serilog was a provider of
Microsoft.Extensions.Logging, and the classes already receiveILogger<T>. With the container option, replace the injectedSerilog.ILoggerwithILogger<T>:// Before public class ProjectService(Serilog.ILogger logger) { public void Save() => logger.Information("Message"); } // After public partial class ProjectService(ILogger<ProjectService> logger) { public void Save() => LogMessage(logger); [LoggerMessage(LogLevel.Information, "Message")] private static partial void LogMessage(ILogger<ProjectService> logger); }
Solution
-
Delete the
installfolder andbuild/Modules/CreateInstallerModule.cs. -
Create a temporary solution with version 6.3.0, and copy the
installerfolder,build/Modules/CreateInstallerModule.cs, andbuild/Options/InstallerOptions.csto the solution. -
Replace the
installproject withinstaller/Installer.csprojin the solution file. -
Register the options in
build/Program.cs:builder.Services.AddOptions<InstallerOptions>().Bind(builder.Configuration.GetSection(InstallerOptions.ConfigurationSectionName)).ValidateDataAnnotations();
-
Add the
Installersection tobuild/appsettings.json, and setUpgradeCodeto the GUID thatinstall/Installer.cspassed toProject.GUID. A new GUID makes the next release install side by side with the previous one.
Tests
-
Update
Nice3point.TUnit.Revitto the latest version. -
Delete
TestsConfiguration.csand remove the executor from the test hooks:// Before [Before(Test)] [HookExecutor<RevitThreadExecutor>] public void SeedModel() // After [Before(Test)] public void SeedModel()
SDK
A project that repacks its assemblies enables PublishAddin or DeployAddin:
<PropertyGroup>
<PublishAddin>true</PublishAddin>
</PropertyGroup>Full changelog: 6.2.3...6.3.0