From bce26dbed5b6089590249cdc2ea0c2f90670ec6d Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Mon, 9 Oct 2023 14:08:05 -0500 Subject: [PATCH] Using a second copy of RAR to resolve IkvmFrameworkReference. This one only includes IKVM related packages and Framework related stuff, and runs before compiling the IkvmReferences. --- .../buildTransitive/IKVM.Image.targets | 2 +- .../IKVM.MSBuild.Tests.csproj | 6 +- .../Project/Exe/ProjectExe.csproj | 11 +++ .../Project/Lib/ProjectLib.csproj | 4 +- src/IKVM.MSBuild.Tests/ProjectTests.cs | 2 + .../buildTransitive/IKVM.MSBuild.targets | 19 ---- src/IKVM.NET.Sdk.Tests/ProjectTests.cs | 86 +++++++++++------ src/IKVM/buildTransitive/IKVM.NoTasks.targets | 6 +- src/IKVM/buildTransitive/IKVM.Tasks.targets | 4 +- src/IKVM/buildTransitive/IKVM.targets | 92 +++++++++++++------ 10 files changed, 146 insertions(+), 86 deletions(-) diff --git a/src/IKVM.Image/buildTransitive/IKVM.Image.targets b/src/IKVM.Image/buildTransitive/IKVM.Image.targets index 83aacc35a0..77de291747 100644 --- a/src/IKVM.Image/buildTransitive/IKVM.Image.targets +++ b/src/IKVM.Image/buildTransitive/IKVM.Image.targets @@ -127,7 +127,7 @@ - + <_FilterIkvmImageItems Items="@(_IkvmImageItemExpanded)"> diff --git a/src/IKVM.MSBuild.Tests/IKVM.MSBuild.Tests.csproj b/src/IKVM.MSBuild.Tests/IKVM.MSBuild.Tests.csproj index 1bd064d63a..9ac8a1ed1c 100644 --- a/src/IKVM.MSBuild.Tests/IKVM.MSBuild.Tests.csproj +++ b/src/IKVM.MSBuild.Tests/IKVM.MSBuild.Tests.csproj @@ -8,14 +8,14 @@ - + - + PreserveNewest - + PreserveNewest diff --git a/src/IKVM.MSBuild.Tests/Project/Exe/ProjectExe.csproj b/src/IKVM.MSBuild.Tests/Project/Exe/ProjectExe.csproj index 676fda96a8..7826b6e72b 100644 --- a/src/IKVM.MSBuild.Tests/Project/Exe/ProjectExe.csproj +++ b/src/IKVM.MSBuild.Tests/Project/Exe/ProjectExe.csproj @@ -17,5 +17,16 @@ + + + + + + helloworld-2 + 2.1.0.0 + helloworld2 + + + diff --git a/src/IKVM.MSBuild.Tests/Project/Lib/ProjectLib.csproj b/src/IKVM.MSBuild.Tests/Project/Lib/ProjectLib.csproj index 5624003b1e..2ba2315168 100644 --- a/src/IKVM.MSBuild.Tests/Project/Lib/ProjectLib.csproj +++ b/src/IKVM.MSBuild.Tests/Project/Lib/ProjectLib.csproj @@ -17,10 +17,10 @@ - + - + helloworld-2 2.1.0.0 helloworld2 diff --git a/src/IKVM.MSBuild.Tests/ProjectTests.cs b/src/IKVM.MSBuild.Tests/ProjectTests.cs index 687a46deab..40e6be36a4 100644 --- a/src/IKVM.MSBuild.Tests/ProjectTests.cs +++ b/src/IKVM.MSBuild.Tests/ProjectTests.cs @@ -188,8 +188,10 @@ public void CanBuildTestProject(string tfm, string rid, string exe, string lib) options.GlobalProperties["TargetFramework"] = tfm; options.GlobalProperties["RuntimeIdentifier"] = rid; options.TargetsToBuild.Clear(); + options.TargetsToBuild.Add("Clean"); options.TargetsToBuild.Add("Build"); options.TargetsToBuild.Add("Publish"); + options.Arguments.Add("/v:diag"); analyzer.Build(options).OverallSuccess.Should().Be(true); var binDir = Path.Combine("Project", "Exe", "bin", "Release", tfm, rid); diff --git a/src/IKVM.MSBuild/buildTransitive/IKVM.MSBuild.targets b/src/IKVM.MSBuild/buildTransitive/IKVM.MSBuild.targets index c2488641b8..c9cb666ccb 100644 --- a/src/IKVM.MSBuild/buildTransitive/IKVM.MSBuild.targets +++ b/src/IKVM.MSBuild/buildTransitive/IKVM.MSBuild.targets @@ -44,25 +44,6 @@ - - - $(ResolveIkvmBaseAssemblyDependsOn); - ResolvePackageDependenciesForBuild; - ResolveProjectReferences; - - - - - - - <_IkvmBaseAssembly Include="@(Reference);@(_ResolvedProjectReferencePaths)" Condition=" '%(Filename)%(Extension)' == 'IKVM.Java.dll' " /> - - - @(_IkvmBaseAssembly) - - - - diff --git a/src/IKVM.NET.Sdk.Tests/ProjectTests.cs b/src/IKVM.NET.Sdk.Tests/ProjectTests.cs index a0c882638d..c4b416e652 100644 --- a/src/IKVM.NET.Sdk.Tests/ProjectTests.cs +++ b/src/IKVM.NET.Sdk.Tests/ProjectTests.cs @@ -58,8 +58,6 @@ public override void Initialize(IEventSource eventSource) public static string IkvmExportCachePath { get; set; } - public TestContext TestContext { get; set; } - [ClassInitialize] public static void Init(TestContext context) { @@ -132,32 +130,34 @@ public static void ClassCleanup() Directory.Delete(TempRoot, true); } + public TestContext TestContext { get; set; } + [DataTestMethod] - [DataRow("net472", "win-x86")] - [DataRow("net472", "win-x64")] - [DataRow("net48", "win-x86")] - [DataRow("net48", "win-x64")] - [DataRow("net6.0", "win-x86")] - [DataRow("net6.0", "win-x64")] - [DataRow("net6.0", "linux-x64")] - [DataRow("net6.0", "linux-arm")] - [DataRow("net6.0", "linux-arm64")] - [DataRow("net6.0", "linux-musl-x64")] - [DataRow("net6.0", "linux-musl-arm")] - [DataRow("net6.0", "linux-musl-arm64")] - [DataRow("net6.0", "osx-x64")] - [DataRow("net6.0", "osx-arm64")] - [DataRow("net7.0", "win-x86")] - [DataRow("net7.0", "win-x64")] - [DataRow("net7.0", "linux-x64")] - [DataRow("net7.0", "linux-arm")] - [DataRow("net7.0", "linux-arm64")] - [DataRow("net7.0", "linux-musl-x64")] - [DataRow("net7.0", "linux-musl-arm")] - [DataRow("net7.0", "linux-musl-arm64")] - [DataRow("net7.0", "osx-x64")] - [DataRow("net7.0", "osx-arm64")] - public void CanBuildTestProject(string tfm, string rid) + [DataRow("net472", "win-x86", "{0}.exe", "{0}.dll")] + [DataRow("net472", "win-x64", "{0}.exe", "{0}.dll")] + [DataRow("net48", "win-x86", "{0}.exe", "{0}.dll")] + [DataRow("net48", "win-x64", "{0}.exe", "{0}.dll")] + [DataRow("net6.0", "win-x86", "{0}.exe", "{0}.dll")] + [DataRow("net6.0", "win-x64", "{0}.exe", "{0}.dll")] + [DataRow("net6.0", "linux-x64", "{0}", "lib{0}.so")] + [DataRow("net6.0", "linux-arm", "{0}", "lib{0}.so")] + [DataRow("net6.0", "linux-arm64", "{0}", "lib{0}.so")] + [DataRow("net6.0", "linux-musl-x64", "{0}", "lib{0}.so")] + [DataRow("net6.0", "linux-musl-arm", "{0}", "lib{0}.so")] + [DataRow("net6.0", "linux-musl-arm64", "{0}", "lib{0}.so")] + [DataRow("net6.0", "osx-x64", "{0}", "lib{0}.dylib")] + [DataRow("net6.0", "osx-arm64", "{0}", "lib{0}.dylib")] + [DataRow("net7.0", "win-x86", "{0}.exe", "{0}.dll")] + [DataRow("net7.0", "win-x64", "{0}.exe", "{0}.dll")] + [DataRow("net7.0", "linux-x64", "{0}", "lib{0}.so")] + [DataRow("net7.0", "linux-arm", "{0}", "lib{0}.so")] + [DataRow("net7.0", "linux-arm64", "{0}", "lib{0}.so")] + [DataRow("net7.0", "linux-musl-x64", "{0}", "lib{0}.so")] + [DataRow("net7.0", "linux-musl-arm", "{0}", "lib{0}.so")] + [DataRow("net7.0", "linux-musl-arm64", "{0}", "lib{0}.so")] + [DataRow("net7.0", "osx-x64", "{0}", "lib{0}.dylib")] + [DataRow("net7.0", "osx-arm64", "{0}", "lib{0}.dylib")] + public void CanBuildTestProject(string tfm, string rid, string exe, string lib) { // skip framework tests for non-Windows platforms if (tfm == "net472" || tfm == "net48") @@ -190,6 +190,38 @@ public void CanBuildTestProject(string tfm, string rid) options.TargetsToBuild.Add("Build"); options.TargetsToBuild.Add("Publish"); analyzer.Build(options).OverallSuccess.Should().Be(true); + + var binDir = Path.Combine("Project", "Exe", "bin", "Release", tfm, rid); + + // check in build output and publish output + foreach (var i in new[] { "", "publish" }) + { + var outDir = Path.Combine(binDir, i); + + // main artifiacts generated by project + File.Exists(Path.Combine(outDir, string.Format(exe, "ProjectExe"))).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "ProjectLib.dll")).Should().BeTrue(); + + // ikvm libraries + File.Exists(Path.Combine(outDir, "IKVM.Runtime.dll")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "IKVM.Java.dll")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, string.Format(lib, "ikvm"))).Should().BeTrue(); + + // ikvm image direcetories + Directory.Exists(Path.Combine(outDir, "ikvm")).Should().BeTrue(); + Directory.Exists(Path.Combine(outDir, "ikvm", rid)).Should().BeTrue(); + Directory.Exists(Path.Combine(outDir, "ikvm", rid, "bin")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "ikvm", rid, "TRADEMARK")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "tzdb.dat")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "tzmappings")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "currency.data")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "security", "java.policy")).Should().BeTrue(); + File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "security", "java.security")).Should().BeTrue(); + + // ikvm image native libraries + foreach (var libName in new[] { "awt", "fdlibm", "iava", "jvm", "management", "net", "nio", "sunec", "unpack", "verify" }) + File.Exists(Path.Combine(outDir, "ikvm", rid, "bin", string.Format(lib, libName))).Should().BeTrue(); + } } } diff --git a/src/IKVM/buildTransitive/IKVM.NoTasks.targets b/src/IKVM/buildTransitive/IKVM.NoTasks.targets index 7f25b3c120..019fd3307f 100644 --- a/src/IKVM/buildTransitive/IKVM.NoTasks.targets +++ b/src/IKVM/buildTransitive/IKVM.NoTasks.targets @@ -8,11 +8,9 @@ --> - + - - @@ -26,7 +24,7 @@ <_IkvmCompilerReferencePath Remove="@(_IkvmCompilerReferencePath)" /> <_IkvmReferenceItemResolvedReference Remove="@(_IkvmReferenceItemResolvedReference)" /> <_IkvmReferenceItemResolvedReference Include="%(IkvmReferenceItem.ResolvedReferences)" /> - <_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);$(IkvmBaseAssembly);$(IkvmRuntimeAssembly);$(IkvmRuntimeJNIAssembly);@(_IkvmReferenceItemResolvedReference)" /> + <_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);@(_IkvmReferenceItemResolvedReference)" /> diff --git a/src/IKVM/buildTransitive/IKVM.Tasks.targets b/src/IKVM/buildTransitive/IKVM.Tasks.targets index aa600d45af..752d54b7e4 100644 --- a/src/IKVM/buildTransitive/IKVM.Tasks.targets +++ b/src/IKVM/buildTransitive/IKVM.Tasks.targets @@ -11,8 +11,6 @@ - - @@ -24,7 +22,7 @@ <_IkvmCompilerReferencePath Remove="@(_IkvmCompilerReferencePath)" /> <_IkvmReferenceItemResolvedReference Remove="@(_IkvmReferenceItemResolvedReference)" /> <_IkvmReferenceItemResolvedReference Include="%(IkvmReferenceItem.ResolvedReferences)" /> - <_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);$(IkvmBaseAssembly);$(IkvmRuntimeAssembly);$(IkvmRuntimeJNIAssembly);@(_IkvmReferenceItemResolvedReference)" /> + <_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);@(_IkvmReferenceItemResolvedReference)" /> diff --git a/src/IKVM/buildTransitive/IKVM.targets b/src/IKVM/buildTransitive/IKVM.targets index 99c86b2c63..1d7946652e 100644 --- a/src/IKVM/buildTransitive/IKVM.targets +++ b/src/IKVM/buildTransitive/IKVM.targets @@ -6,18 +6,70 @@ $(ResolveIkvmFrameworkReferencesDependsOn); - ResolveAssemblyReferences; - - - - - - - + + + <_IkvmFrameworkAssemblyReference Include="@(Reference)" Condition=" '%(Reference.NuGetIsFrameworkReference)' == 'true' Or '%(Reference.FrameworkFile)' == 'true' Or '%(Reference.ResolvedFrom)' == '{TargetFrameworkDirectory}' Or '%(Reference.IsImplicitlyDefined)' == 'true' Or '%(Reference.FrameworkReferenceName)' != '' Or '%(Reference.FrameworkReferenceVersion)' != '' "/> + <_IkvmFrameworkAssemblyReference Include="@(Reference)" Condition=" '%(Reference.Filename)%(Reference.Extension)' == 'IKVM.Runtime.dll' " /> + <_IkvmFrameworkAssemblyReference Include="@(Reference)" Condition=" '%(Reference.Filename)%(Reference.Extension)' == 'IKVM.Java.dll' " /> + <_IkvmReferenceInstalledAssemblyDirectory Include="$(TargetFrameworkDirectory)" /> + <_IkvmReferenceInstalledAssemblySubsets Include="$(TargetFrameworkSubset)" /> + <_IkvmResolveAssemblyReferencesApplicationConfigFileForExes Include="@(AppConfigWithTargetPath)" Condition=" '$(AutoGenerateBindingRedirects)' == 'true' Or '$(AutoUnifyAssemblyReferences)' == 'false' "/> + + + <_ResolveIkvmFrameworkReferencesStateFile Condition=" '$(DisableRarCache)' != 'true' And '$(_ResolveIkvmFrameworkReferencesStateFile)' == '' ">$(IntermediateOutputPath)$(MSBuildProjectFile).IkvmFrameworkReference.cache + <_IkvmResolveFrameworkReferencesSilent Condition="'$(_IkvmResolveFrameworkReferencesSilent)' == '' ">false + <_IkvmResolveFrameworkWarnOrErrorOnTargetArchitectureMismatch Condition=" '$(_IkvmResolveFrameworkWarnOrErrorOnTargetArchitectureMismatch)' == '' ">Warning + + + + + + @@ -30,14 +82,11 @@ - + - - - <_IkvmReferenceReferences Include="$(IkvmRuntimeAssembly);$(IkvmRuntimeJNIAssembly);$(IkvmBaseAssembly)" /> <_IkvmReferenceReferences Include="@(IkvmFrameworkReference)" /> @@ -68,7 +117,7 @@ - + @@ -88,17 +137,14 @@ - + ResolveIkvmReferences %(IkvmReferenceItem.CachePath) %(IkvmReferenceItem.Aliases) %(IkvmReferenceItem.Private) - %(IkvmReferenceItem.CopyLocal) %(IkvmReferenceItem.ReferenceOutputAssembly) %(IkvmReferenceItem.Compile) - - - + @@ -111,18 +157,10 @@ - + - - - - ResolveIkvmReferences; - $(ResolveReferencesDependsOn); - - -