Skip to content

Commit 6f94ea9

Browse files
committed
refactor(testing): update NUnit and TUnit packaging and runtime handling
- Consolidate NUnit and TUnit packaging targets, removing merged assemblies props. - Adjust project references to point to the new NUnit runtime packaging targets. - Enhance runtime payload management for NUnit, ensuring proper isolation of host-owned assemblies. - Update test assertions to reflect changes in packaging structure and ownership. - Remove deprecated references and streamline the build process for better clarity.
1 parent 7d4c79e commit 6f94ea9

14 files changed

Lines changed: 115 additions & 217 deletions

File tree

docs/architecture/Testing/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ project, `DevTools.TestRunner`. Runtime sources are Compile-linked into MTP.
105105
one year is rebuilt, and a missing year folder used to skip the copy silently.
106106
Closure copy (`SkipUnchangedFiles=true`) excludes `DevTools.*.MTP.dll`.
107107
Sibling copy always overwrites the selected MTP (`SkipUnchangedFiles=false`)
108-
and prefers the in-repo MTP bin over a leftover `build/runtime` nupkg copy
109-
so testhost discovery cannot keep a timestamp-stale TUnit/NUnit discoverer.
108+
and prefers the in-repo `bin\Debug|Release\$(TFM)\` over a leftover
109+
`build/runtime` nupkg copy. Net48 Testing.Abstractions uses the same order.
110+
Do not fall back to `bin\$(Configuration)\` or a flattened Autodesk folder.
110111

111112
---
112113

@@ -196,6 +197,13 @@ Do not add a shared runtime-descriptor catalog. Policy constants stay on the
196197
provider type. NUnit/TUnit Host csproj remove the solution `Polyfill` global
197198
package so net48 does not collide with `DevTools.Testing.Host`.
198199

200+
Each provider uses two targets files: `*RuntimePayload.targets` (Runtime owns
201+
a payload folder) then `*HostPackaging.targets` (add-in copies that folder to
202+
`NUnitRuntime\` / `TUnitRuntime\`). NUnit payload excludes host-owned
203+
JSON/Ipc/Isolation/Abstractions. TUnit copies its full private closure.
204+
net48 pins STJ 9 copy-local in `DevTools.TUnit.Runtime`; the host keeps
205+
STJ 10 (MCP / ILRepack).
206+
199207
### Test output
200208

201209
`TestingRunTraceScope` buffers `Trace` / `Debug` per case. NUnit and TUnit

docs/product/tunit-host-testing.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ In-host Engine execution clears `SynchronizationContext` so
132132
`TUnitRuntime` ships `TUnit.Core`, `TUnit.Engine`, and
133133
`Microsoft.Testing.Platform` under `TUnitRuntime\`, not at the add-in
134134
root. Collectible load contexts apply on modern host TFMs. .NET Framework
135-
years use scoped isolation and exact manifest identity resolution,
136-
including side-by-side `System.Text.Json` identities.
135+
years use scoped isolation and exact manifest identity resolution.
137136

138137
TUnit.Core `Sources.TestEntries` is a process-wide dictionary keyed by
139138
`Type`. A rebuild loads a new test assembly (net48 cannot unload the old

samples/Sample.slnx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,20 @@
3333
</Project>
3434
</Folder>
3535
<Folder Name="/Testing/">
36-
<Project Path="../source/DevTools.TestAdapter/DevTools.TestAdapter.csproj" />
36+
<Project Path="../source/DevTools.TestAdapter/DevTools.TestAdapter.csproj">
37+
<BuildType Solution="Debug.Autodesk.2022|*" Project="Debug" />
38+
<BuildType Solution="Debug.Autodesk.2023|*" Project="Debug" />
39+
<BuildType Solution="Debug.Autodesk.2024|*" Project="Debug" />
40+
<BuildType Solution="Debug.Autodesk.2025|*" Project="Debug" />
41+
<BuildType Solution="Debug.Autodesk.2026|*" Project="Debug" />
42+
<BuildType Solution="Debug.Autodesk.2027|*" Project="Debug" />
43+
<BuildType Solution="Release.Autodesk.2022|*" Project="Release" />
44+
<BuildType Solution="Release.Autodesk.2023|*" Project="Release" />
45+
<BuildType Solution="Release.Autodesk.2024|*" Project="Release" />
46+
<BuildType Solution="Release.Autodesk.2025|*" Project="Release" />
47+
<BuildType Solution="Release.Autodesk.2026|*" Project="Release" />
48+
<BuildType Solution="Release.Autodesk.2027|*" Project="Release" />
49+
</Project>
3750
<Project Path="DevTools.NUnit.Civil3D.SampleTests/DevTools.NUnit.Civil3D.SampleTests.csproj" />
3851
<Project Path="DevTools.NUnit.SampleTests/DevTools.NUnit.SampleTests.csproj" />
3952
<Project Path="DevTools.TUnit.Civil3D.SampleTests/DevTools.TUnit.Civil3D.SampleTests.csproj" />

source/ACadDevTool/ACadDevTool.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<Using Include="ZLogger.Providers" />
5858
</ItemGroup>
5959

60-
<Import Project="..\DevTools.NUnit.Host\build\NUnitHostPackaging.targets" />
60+
<Import Project="..\DevTools.NUnit.Runtime\build\NUnitHostPackaging.targets" />
6161
<Import Project="..\DevTools.TUnit.Runtime\build\TUnitHostPackaging.targets" />
6262

6363
<!-- Start AutoCad -->

source/DevTools.NUnit.Host/build/NUnitHostMergedAssemblies.props

Lines changed: 0 additions & 20 deletions
This file was deleted.

source/DevTools.NUnit.Host/build/NUnitHostPackaging.targets

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<Project>
2+
<!--
3+
Copy Runtime-owned NUnitRuntimePayload\ into $(TargetDir)NUnitRuntime\.
4+
Never use bare $(OutputPath) — empty OutputPath creates source/NUnitRuntime\.
5+
-->
6+
<PropertyGroup>
7+
<NUnitRuntimeProject Condition="'$(NUnitRuntimeProject)' == ''">$(MSBuildThisFileDirectory)..\DevTools.NUnit.Runtime.csproj</NUnitRuntimeProject>
8+
</PropertyGroup>
9+
10+
<Target Name="CopyNUnitRuntimeBootstrap"
11+
AfterTargets="Build"
12+
BeforeTargets="RepackAddinFiles"
13+
Condition="'$(TargetPath)' != '' AND '$(TargetDir)' != ''">
14+
<PropertyGroup>
15+
<_NUnitRuntimeDeployDir>$([System.IO.Path]::GetFullPath('$(TargetDir)NUnitRuntime\'))</_NUnitRuntimeDeployDir>
16+
</PropertyGroup>
17+
<MSBuild Projects="$(NUnitRuntimeProject)"
18+
Targets="GetNUnitRuntimePayload"
19+
Properties="Configuration=$(Configuration);TargetFramework=$(TargetFramework)">
20+
<Output TaskParameter="TargetOutputs" ItemName="_NUnitRuntimePayload" />
21+
</MSBuild>
22+
<Error Condition="'@(_NUnitRuntimePayload)' == ''"
23+
Text="NUnit runtime payload from '$(NUnitRuntimeProject)' was empty (TargetFramework=$(TargetFramework))." />
24+
<RemoveDir Directories="$(_NUnitRuntimeDeployDir)" Condition="Exists('$(_NUnitRuntimeDeployDir)')" />
25+
<MakeDir Directories="$(_NUnitRuntimeDeployDir)" />
26+
<Copy SourceFiles="@(_NUnitRuntimePayload)"
27+
DestinationFolder="$(_NUnitRuntimeDeployDir)"
28+
SkipUnchangedFiles="false" />
29+
</Target>
30+
31+
<Target Name="AssertNUnitRuntimeLayout"
32+
AfterTargets="RepackAddinFiles"
33+
Condition="'$(ILRepackable)' == 'true' AND '$(TargetDir)' != ''">
34+
<Error Condition="!Exists('$(TargetDir)NUnitRuntime\DevTools.NUnit.Runtime.dll')"
35+
Text="DevTools.NUnit.Runtime.dll must be deployed under NUnitRuntime\." />
36+
<Error Condition="!Exists('$(TargetDir)NUnitRuntime\nunit.framework.dll')"
37+
Text="nunit.framework.dll must be deployed under NUnitRuntime\." />
38+
<Error Condition="!Exists('$(TargetDir)DevTools.Testing.Abstractions.dll')"
39+
Text="DevTools.Testing.Abstractions.dll must stay loose beside the add-in." />
40+
<Error Condition="Exists('$(TargetDir)NUnitRuntime\DevTools.Testing.Abstractions.dll')"
41+
Text="DevTools.Testing.Abstractions.dll must not ship inside NUnitRuntime\." />
42+
<Error Condition="Exists('$(TargetDir)DevTools.NUnit.Runtime.dll') OR Exists('$(TargetDir)nunit.framework.dll') OR Exists('$(TargetDir)DevTools.NUnit.Runner.exe')"
43+
Text="NUnit Runtime, nunit.framework, and DevTools.NUnit.Runner.exe must not be copied at the add-in root." />
44+
<Error Condition="Exists('$(TargetDir)DevTools.Ipc.dll') OR Exists('$(TargetDir)System.Text.Json.dll') OR Exists('$(TargetDir)System.Text.Encodings.Web.dll') OR Exists('$(TargetDir)System.IO.Pipelines.dll') OR Exists('$(TargetDir)Microsoft.Bcl.AsyncInterfaces.dll') OR Exists('$(TargetDir)DevTools.AssemblyIsolation.dll') OR Exists('$(TargetDir)DevTools.Testing.Host.dll') OR Exists('$(TargetDir)DevTools.Testing.Transport.dll')"
45+
Text="Host JSON/IPC/Isolation/Testing.Host/Transport must stay merged into the add-in." />
46+
<Error Condition="Exists('$(TargetDir)NUnitRuntime\DevTools.Ipc.dll') OR Exists('$(TargetDir)NUnitRuntime\System.Text.Json.dll') OR Exists('$(TargetDir)NUnitRuntime\System.Text.Encodings.Web.dll') OR Exists('$(TargetDir)NUnitRuntime\System.IO.Pipelines.dll') OR Exists('$(TargetDir)NUnitRuntime\Microsoft.Bcl.AsyncInterfaces.dll') OR Exists('$(TargetDir)NUnitRuntime\DevTools.AssemblyIsolation.dll')"
47+
Text="Host-owned assemblies must not ship inside NUnitRuntime\." />
48+
</Target>
49+
</Project>

0 commit comments

Comments
 (0)