diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 47ec1bb21e..bce7bb9016 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -9,6 +9,7 @@
+
@@ -18,7 +19,6 @@
-
diff --git a/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj b/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj
index f1a123a254..53bd14bd0b 100644
--- a/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj
+++ b/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj
@@ -1,7 +1,7 @@
-
+
diff --git a/src/GitVersion.App.Tests/VersionWriterTests.cs b/src/GitVersion.App.Tests/VersionWriterTests.cs
index 556fe58221..36c70d08c3 100644
--- a/src/GitVersion.App.Tests/VersionWriterTests.cs
+++ b/src/GitVersion.App.Tests/VersionWriterTests.cs
@@ -1,7 +1,8 @@
using GitVersion.Core.Tests.Helpers;
using GitVersion.Extensions;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
using Microsoft.Extensions.DependencyInjection;
-using Mono.Cecil;
namespace GitVersion.App.Tests;
@@ -46,17 +47,16 @@ public void WriteVersionShouldWriteFileVersionWithPrereleaseTag()
private static Assembly GenerateAssembly(Version fileVersion, string prereleaseInfo)
{
- var definition = new AssemblyNameDefinition("test-asm", fileVersion);
-
- var asmDef = AssemblyDefinition.CreateAssembly(definition, "test-asm", ModuleKind.Dll);
- var constructor = typeof(AssemblyInformationalVersionAttribute).GetConstructor(new[] { typeof(string) });
- var methodReference = asmDef.MainModule.ImportReference(constructor);
- var customAttribute = new CustomAttribute(methodReference);
- customAttribute.ConstructorArguments.Add(new CustomAttributeArgument(asmDef.MainModule.TypeSystem.String, fileVersion + prereleaseInfo));
- asmDef.CustomAttributes.Add(customAttribute);
+ var attribute = typeof(AssemblyInformationalVersionAttribute);
+ var csharpCode = $@"[assembly: {attribute.FullName}(""{fileVersion + prereleaseInfo}"")]";
+ var compilation = CSharpCompilation.Create("test-asm")
+ .WithOptions(new(OutputKind.DynamicallyLinkedLibrary))
+ .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location))
+ .AddReferences(MetadataReference.CreateFromFile(attribute.Assembly.Location))
+ .AddSyntaxTrees(CSharpSyntaxTree.ParseText(csharpCode));
using var memoryStream = new MemoryStream();
- asmDef.Write(memoryStream);
+ compilation.Emit(memoryStream);
return Assembly.Load(memoryStream.ToArray());
}