ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.26k stars 118 forks source link

IkvmCompiler MSBuild task using incorrect stage directory. #282

Closed wasabii closed 1 year ago

wasabii commented 1 year ago
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018: The "IkvmCompiler" task failed unexpectedly. [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path '/src/Infrastructure/OurProject.SomePath.Infrastructure/obj/Release/net7.0/linux-x64/ikvm/stage/1/b677e6d5a61a3768a4b8295db55e187f/jeval-net.dll.dll.rsp'. [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at System.IO.File.WriteToFile(String path, FileMode mode, String contents, Encoding encoding) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at IKVM.Tools.Runner.Compiler.IkvmCompilerLauncher.ExecuteAsync(IkvmCompilerOptions options, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.Tools.Runner\Compiler\IkvmCompilerLauncher.cs:line 259 [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at IKVM.MSBuild.Tasks.IkvmCompiler.ExecuteAsync(IkvmToolTaskDiagnosticWriter writer, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmCompiler.cs:line 273 [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at IKVM.MSBuild.Tasks.IkvmToolExecTask.Execute() in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmToolExecTask.cs:line 79 [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
wasabii commented 1 year ago

Copied from #281, as this is a distinct issue.

wasabii commented 1 year ago

This problem was also reported by @NightOwl888 at https://github.com/ikvm-revived/ikvm-maven/issues/29

wasabii commented 1 year ago

A workaround should be to ensure that your invocation of MSBuild is not running in parallel. That is, ensure you aren't passing /m to MSBuild, and aren't setting BuildInParallel.

wasabii commented 1 year ago

The underlying issue was the IkvmCompilerTask (and others) yielding to the engine to continue potential parallel tasks, while IkvmCompiler itself attempted to determine files by using Environment.CurrentDirectory. MSBuild sets Environment.CurrentDirectory to the current project path. But, if you yield back to the engine, MSBuild is free to reset it to whatever Project it is working on at the moment. Environment.CurrentDirectory is a process wide value.

Solution was to resolve relative paths to absolute paths before yielding back to the engine. That way no relative resolution is attempted down the code path.

NightOwl888 commented 1 year ago

Great. Any chance we can roll a prerelease?

wasabii commented 1 year ago

https://www.nuget.org/packages/IKVM/8.4.5-prerelease0001

Can ya'll please test this?

NightOwl888 commented 1 year ago

The error is gone. But now I am getting mysterious warnings that don't have a warning message. In the logs, the threads are numbered so I can see they are all happening on the IKVM.Tests project and none of the other projects are now complaining.

The fact that they are repeating 3 times can be explained by the project targeting 3 TFMs even though the first 2 don't report the TFM.

I am targeting IKVM.Maven.Sdk 1.2.0 and IKVM 8.4.5-prerelease0001. These warnings didn't occur when I was targeting IKVM.Maven.Sdk 1.2.0 and IKVM 8.4.0.

Here is an example. I removed the satellite assembly copy code to rule that out.

Build succeeded.

       "D:\a\1\s\IkvmPublishDemo.sln" (default target) (1:2) ->
       "D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj" (default target) (3:18) ->
       "D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj" (Build target) (3:20) ->
       (_CompileIkvmReferences target) -> 
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning : ikvmc (8.4.5-prerelease.1+5.Branch.hotfix-8.4.5.Sha.66c1b7ebb582c8eac4f114eb922c1e665c7080f6) [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj]
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning : Copyright c 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj]
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning :  [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj]

       "D:\a\1\s\IkvmPublishDemo.sln" (default target) (1:2) ->
       "D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj" (default target) (3:18) ->
       "D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj" (Build target) (3:21) ->
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning : ikvmc (8.4.5-prerelease.1+5.Branch.hotfix-8.4.5.Sha.66c1b7ebb582c8eac4f114eb922c1e665c7080f6) [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj]
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning : Copyright c 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj]
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning :  [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj]

       "D:\a\1\s\IkvmPublishDemo.sln" (default target) (1:2) ->
       "D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj" (default target) (3:18) ->
       "D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj" (Build target) (3:19) ->
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning : ikvmc (8.4.5-prerelease.1+5.Branch.hotfix-8.4.5.Sha.66c1b7ebb582c8eac4f114eb922c1e665c7080f6) [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj::TargetFramework=net6.0]
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning : Copyright c 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj::TargetFramework=net6.0]
         C:\Users\VssAdministrator\.nuget\packages\ikvm\8.4.5-prerelease0001\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): warning :  [D:\a\1\s\tests\ICU4N.Tests\ICU4N.Tests.csproj::TargetFramework=net6.0]

    9 Warning(s)
    0 Error(s)
wasabii commented 1 year ago

That's the copyright message. Pretty sure those have been around for awhile. I removed the copyright message on the dev branch, but haven't done anything with it on release.

We've had a previous bug report about it, so I know it's been around for awhile.

shapeh commented 1 year ago

8.4.5 has solved the problems here.