Skip to content

Commit

Permalink
Fix Installation Application issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Apr 2, 2024
1 parent 4334aab commit 29fec4f
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Build/Build.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>.</NukeRootDirectory>
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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.3.1] / 2024-04-02
### Fixed
- Fix `Installation` Application issue.
### Updated
- Update `ricaun.Revit.Installation`

## [1.3.0] / 2024-03-28
### Features
- Readme information to wiki.
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.3.0</Version>
<Version>1.3.1-alpha</Version>
</PropertyGroup>
</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,47 @@ namespace ricaun.RevitTest.Console.Revit.Services
public class ApplicationPluginsDisposable : IDisposable
{
private readonly string applicationPluginsPath;
private readonly bool applicationPluginsPathDelete;
private Action<Exception> downloadException;
private Action<string> logConsole;

public bool Initialized { get; private set; }
public ApplicationPluginsDisposable(string applicationPluginsPath)
{
this.applicationPluginsPath = applicationPluginsPath;
Initialize();
}
public ApplicationPluginsDisposable(byte[] data, string fileName)
{
this.applicationPluginsPath = data.CopyToFile(fileName);
Initialize();
File.Delete(this.applicationPluginsPath);
this.applicationPluginsPathDelete = true;
}
private void Initialize()

public ApplicationPluginsDisposable SetException(Action<Exception> downloadException)
{
if (string.IsNullOrEmpty(applicationPluginsPath)) return;
this.downloadException = downloadException;
return this;
}

public ApplicationPluginsDisposable SetLog(Action<string> logConsole)
{
this.logConsole = logConsole;
return this;
}

public ApplicationPluginsDisposable Initialize()
{
if (string.IsNullOrEmpty(applicationPluginsPath)) return this;
var applicationPluginsFolder = RevitUtils.GetCurrentUserApplicationPluginsFolder();
ApplicationPluginsUtils.DownloadBundle(applicationPluginsFolder, applicationPluginsPath);
Initialized = ApplicationPluginsUtils.DownloadBundle(applicationPluginsFolder, applicationPluginsPath, downloadException, logConsole);

if (applicationPluginsPathDelete)
{
File.Delete(this.applicationPluginsPath);
}

return this;
}

public void Dispose()
{
if (string.IsNullOrEmpty(applicationPluginsPath)) return;
Expand Down
36 changes: 31 additions & 5 deletions ricaun.RevitTest.Console/Revit/Utils/RevitTestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,19 @@ public static void CreateRevitServer(

using (new FileWatcher().Initialize(fileToTest, resetSendFile))
{
using (CreateAppPlugin())
using (var appPlugin = CreateApplicationPlugin())
{
Debug.WriteLine($"Application Install: {appPlugin.Initialized}");

if (appPlugin.Initialized == false)
{
var exceptionAppPlugin = new Exception("Application not initialized.");
var failTests = TestEngine.Fail(fileToTest, exceptionAppPlugin, testFilters);
actionOutput.Invoke(failTests.ToJson());
Thread.Sleep(SleepMillisecondsBeforeFinish);
return;
}

if (RevitInstallationUtils.InstalledRevit.TryGetRevitInstallationGreater(revitVersionNumber, out RevitInstallation revitInstallation))
{
Log.WriteLine(revitInstallation);
Expand Down Expand Up @@ -256,11 +267,26 @@ public static void CreateRevitServer(
}

#region private
private static ApplicationPluginsDisposable CreateAppPlugin()
private static ApplicationPluginsDisposable CreateApplicationPlugin()
{
var application = new ApplicationPluginsDisposable(
Properties.Resources.ricaun_RevitTest_Application_bundle,
"ricaun.RevitTest.Application.bundle.zip");

application.SetException(ApplicationException);
application.SetLog(ApplicationLog);

return application.Initialize();
}

private static void ApplicationException(Exception exception)
{
Debug.WriteLine($"Application Error: {exception.Message}");
}

private static void ApplicationLog(string log)
{
return new ApplicationPluginsDisposable(
Properties.Resources.ricaun_RevitTest_Application_bundle,
"ricaun.RevitTest.Application.bundle.zip");
Debug.WriteLine($"Application: {log}");
}
#endregion
}
Expand Down
2 changes: 1 addition & 1 deletion ricaun.RevitTest.Console/ricaun.RevitTest.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ricaun.Revit.Installation" Version="*" />
<PackageReference Include="ricaun.Revit.Installation" Version="*-*" />
<PackageReference Include="Microsoft.VisualStudio.Interop" Version="*" />
</ItemGroup>

Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions ricaun.RevitTest.Tests/TestRevitTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ public void Initialize()
RevitTask.Initialize();
}

#if !(NET)
[Test]
public async Task TestAsync_MacroManager()
{
await RevitTask.Run((uiapp) =>
{
uiapp.PostCommand(RevitCommandId.LookupPostableCommandId(PostableCommand.MacroManager));
uiapp.DialogBoxShowing += DialogBoxShowingForceClose;
uiapp.PostCommand(RevitCommandId.LookupPostableCommandId(PostableCommand.MacroManager));
});

await RevitTask.Run((uiapp) =>
Expand All @@ -42,7 +43,7 @@ private void DialogBoxShowingForceClose(object sender, Autodesk.Revit.UI.Events.
Console.WriteLine($"DialogBoxShowing {e.DialogId}");
e.OverrideResult((int)TaskDialogResult.Close);
}

#endif
[Test]
public async Task TestAsync_Idling()
{
Expand Down
22 changes: 19 additions & 3 deletions ricaun.RevitTest.Tests/ricaun.RevitTest.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@

<PropertyGroup>
<IsTestProject>true</IsTestProject>
<TargetFramework>net48</TargetFramework>
<RevitVersion>2021</RevitVersion>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>

<!-- RevitVersion -->
<PropertyGroup>
<TargetFrameworks>net48;net8.0-windows</TargetFrameworks>
</PropertyGroup>
<Choose>
<When Condition="$(TargetFramework.StartsWith('net4'))">
<PropertyGroup>
<RevitVersion>2024</RevitVersion>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<RevitVersion>2025</RevitVersion>
</PropertyGroup>
</Otherwise>
</Choose>

<!-- Release -->
<PropertyGroup Condition="!$(Configuration.Contains('Debug'))">
<Optimize>true</Optimize>
Expand All @@ -32,6 +47,7 @@

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" Condition="!$(TargetFramework.StartsWith('net4'))"/>
<ProjectReference Include="..\ricaun.RevitTest.TestAdapter\ricaun.RevitTest.TestAdapter.csproj">
<Private></Private>
<PrivateAssets>true</PrivateAssets>
Expand All @@ -40,7 +56,7 @@

<ItemGroup>
<PackageReference Include="ricaun.Revit.Async" Version="*" />
<PackageReference Include="Revit_All_Main_Versions_API_x64" Version="$(RevitVersion).*" IncludeAssets="build; compile" PrivateAssets="All" />
<PackageReference Include="Revit_All_Main_Versions_API_x64" Version="$(RevitVersion).*-*" IncludeAssets="build; compile" PrivateAssets="All" />
</ItemGroup>

</Project>

0 comments on commit 29fec4f

Please sign in to comment.