Skip to content

Commit 8f7ddcd

Browse files
authored
[build] Fix 'BuildVersionInfo_g_cs' build target. (#881)
Commit 3e6a623 added a new target 'BuildVersionInfo_g_cs', which is responsible for generating the file `$(IntermediateOutputPath)$(AssemblyName).AssemblyInfo.g.cs)`. Unfortunately, it turns out that`$(IntermediateOutputPath)` has not been created when the target is run, so we error out: …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: The "GenerateVersionFile" task failed unexpectedly. …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path "…/external/Java.Interop/src/Java.Interop/obj/Release-monoandroid10/Java.Interop.AssemblyInfo.g.cs". …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions) …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize) …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at System.IO.StreamWriter..ctor (System.String path) …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at (wrapper remoting-invoke-with-check) System.IO.StreamWriter..ctor(string) …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at System.IO.File.WriteAllText (System.String path, System.String contents) …/Java.Interop/src/Java.Interop/Directory.Build.targets(44,5): error MSB4018: at Java.Interop.BootstrapTasks.GenerateVersionFile.Execute () Ensure that `$(IntermediateOutputPath)` exists by moving the `BuildVersionInfo_g_cs` target to run *after* the `BuildJniEnvironment_g_cs` target, which creates `$(IntermediateOutputPath)`. Additionally, update the Condition which sets `$(JIBuildingForNetCoreApp)` so that `$(JIBuildingForNetCoreApp)` is *not* when `$(TargetFramework)` starts with `monoandroid`. This avoids the error: error MSB3073: The command "$HOME/android-toolchain/dotnet/dotnet "…/Java.Interop/bin/BuildDebug-monoandroid10/jnienv-gen.dll" Java.Interop/JniEnvironment.g.cs obj/Debug-monoandroid10/jni.c" exited with code 1
1 parent 7068f4b commit 8f7ddcd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<AppendTargetFrameworkToOutputPath Condition=" '$(AppendTargetFrameworkToOutputPath)' == '' ">False</AppendTargetFrameworkToOutputPath>
4141
<BaseIntermediateOutputPath Condition=" '$(BaseIntermediateOutputPath)' == '' ">obj\</BaseIntermediateOutputPath>
4242
</PropertyGroup>
43-
<PropertyGroup Condition=" ( '$(TargetFramework)' != '' AND !$(TargetFramework.StartsWith('nets'))) AND (!$(TargetFramework.StartsWith('net4'))) ">
43+
<PropertyGroup Condition=" '$(TargetFramework)' != '' And (!$(TargetFramework.StartsWith('nets')) And !$(TargetFramework.StartsWith('net4')) And !$(TargetFramework.StartsWith('monoandroid'))) ">
4444
<JIBuildingForNetCoreApp>True</JIBuildingForNetCoreApp>
4545
</PropertyGroup>
4646
<PropertyGroup Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">

src/Java.Interop/Java.Interop-MonoAndroid.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
<Import Project="Directory.Build.targets" />
8787
<PropertyGroup>
8888
<BuildDependsOn>
89-
BuildVersionInfo_g_cs;
9089
BuildJniEnvironment_g_cs;
90+
BuildVersionInfo_g_cs;
9191
BuildInteropJar;
9292
$(BuildDependsOn)
9393
</BuildDependsOn>

0 commit comments

Comments
 (0)