-
Notifications
You must be signed in to change notification settings - Fork 64
[Java.Interop] $(Version) depends on TargetFramework #947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Context: dotnet/java-interop#947 Does It Build™?
Context: 2d5431f Context: 88d6093 Context: dotnet#936 Context: https://github.com/jonpryor/java.interop/commits/jonp-registration-scope Versioning is hard. Way back in 3e6a623 we tried to use the `GitInfo` NuGet package so that *all* assemblies would have a version number which contained the number of commits since `GitInfo.txt` changed. This turned out to have unanticipated breakage, and was largely reverted in 2d5431f for "core" libs like `Java.Interop.dll`. This still presents a problem, though: the *point* to assembly versioning is to prevent accidental breaking of referencing assemblies. If we add a new member to `Java.Interop.dll` but *fail to update the version*, then that *permits* a scenario in which an app/lib depends on the new member, but is built against a version missing that member. This result in runtime exceptions. The whole reason this hasn't been a problem so far is because `Java.Interop.dll` has barely changed in *years*. (Plus, most usage is hidden behind other layers and libs…) However, *I want this to change*: dotnet#936 and jonpryor/java.interop/jonp-registration-scope both *add* new public API to `Java.Interop.dll`, and there are other features and optimizations we're considering that would also require API changes. A policy of "no changes" isn't tenable. Thus, the first priority: allow `Java.Interop.dll` built for .NET 6 to have a different `$(Version)` than the one built for .NET Standard 2.0. Fixing this was unexpectedly problematic, as commit 88d6093: > Update[d] `Java.Interop.BootstrapTasks.csproj` to *no longer* `<Import/>` > `VersionInfo.targets`, as this causes a circular dependency > (`VersionInfo.targets` uses tasks from > `Java.Interop.BootstrapTasks.dll`). This is fine, as > `Java.Interop.BootstrapTasks.dll` doesn't need to be versioned. `Java.Interop.BootstrapTasks.dll` doesn't need to be versioned, but *other libraries **do***, and this change change meant that `VersionInfo.targets` was *never* used, which in turn meant that e.g. `bin/BuildDebug/Version.props` was never created. Re-introduce `VersionInfo.targets` by "moving" it into `build-tools/VersionInfo/VersionInfo.csproj`, and adding `VersionInfo.csproj` to `Java.Interop.BootstrapTasks.sln`. This allows the `Prepare` target to create `bin/Build$(Configuration)/Version.props`. Next, update `Java.Interop.csproj` so that `$(Version)` is *conditional* on `$(TargetFramework)`. This allows it to continue using version 0.1.0.0 for .NET Standard 2.0, and begin using 6.0.0.* for .NET 6+ builds. Finally -- and most of the "noise" in this commit -- "cleanup and unify" the disparate build systems. `make prepare all` is one world, while `dotnet` is a different and overlapping world. Clean this up: the `dotnet`-based MSBuild environment is now our Source Of Truth, and the `make` targets are updated to rely on the `Prepare` target instead of duplicating most of the logic. While cleaning up `Makefile`, remove other cruft such as the explicit `gcc` calls to build the `NativeTiming` lib (we have a `.csproj` as of 5c756b1; use it!), and rationalize `Java.Runtime.Environment.dll.config` generation.
49663cf to
2f1234c
Compare
Context: dotnet/java-interop#947 Does It Build™?
e4dfe26 to
4f436bc
Compare
The **Windows - .NET Core** > **Prepare Solution** step is
failing:
##[error]build-tools\VersionInfo\VersionInfo.csproj(0,0): Error MSB4236: The SDK 'Microsoft.Build.NoTargets' specified could not be found.
D:\a\1\s\build-tools\VersionInfo\VersionInfo.csproj : error MSB4236: The SDK 'Microsoft.Build.NoTargets' specified could not be found.
…which doesn't make sense, as `Microsoft.Build.NoTargets` is
versioned in `global.json`, and similar usage works in
xamarin-android…
Hypothesis: it works elsewhere because the `.sln` is in the same
dir as the `global.json`, which isn't the case here.
Theory: adding `build-tools/global.json` will fix things.
Time to test!
Result: it worked.
Thus, final fix: move `Java.Interop.BootstrapTasks.sln` into topdir,
allowing us to remove `build-tools/global.json`.
Other cleanups done as well.
4f436bc to
d880531
Compare
| </Project> | ||
|
|
||
| <Target Name="_SetInformationalVersion" | ||
| BeforeTargets="GetAssemblyVersion;GetPackageVersion"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to manually check the Java.Interop.dll in the next java.interop bump? Will we remember?
RunTests:
packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe bin\TestRelease\generator-Tests.dll --result="TestResult-generator-Tests.xml" --output="bin\TestRelease\TestOutput-generator-Tests.txt"
'packages' is not recognized as an internal or external command,
operable program or batch file.
##[error]build-tools\scripts\RunNUnitTests.targets(27,5): Error MSB3073: The command " packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe bin\TestRelease\generator-Tests.dll --result="TestResult-generator-Tests.xml" --output="bin\TestRelease\TestOutput-generator-Tests.txt"" exited with code 9009.
D:\a\1\s\build-tools\scripts\RunNUnitTests.targets(27,5): error MSB3073: The command " packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe bin\TestRelease\generator-Tests.dll --result="TestResult-generator-Tests.xml" --output="bin\TestRelease\TestOutput-generator-Tests.txt"" exited with code 9009.
The assumption is that we're not doing `nuget restore` now, so
the package is installed into `~/.nuget/…`, and thus isn't found.
Fix that by "using" `%(PackageReference.GeneratePathProperty)`
in the bootstrap tasks so that we can obtain
`$(PkgNUnit_ConsoleRunner)`, and *generate* that during
`dotnet build -t:Prepare`. That way `RunNUnitTests.targets`
has access to the value.
Pobst doesn't want us to use `6.0.200`; use `6.0` for GitInfo.txt. Remove the `globalPackagesFolder` override; it shouldn't be needed anymore, given dab4b89.
I do not believe we can allow the Imagine I install .NET However, the only versioning that NuGet is aware of is If someone is still using .NET
We can hardcode |
|
Superseded by PR#952. |
Context: 2d5431f
Context: 88d6093
Context: #936
Context: https://github.com/jonpryor/java.interop/commits/jonp-registration-scope
Versioning is hard.
Way back in 3e6a623 we tried to use the
GitInfoNuGet package sothat all assemblies would have a version number which contained the
number of commits since
GitInfo.txtchanged.This turned out to have unanticipated breakage, and was largely
reverted in 2d5431f for "core" libs like
Java.Interop.dll.This still presents a problem, though: the point to assembly
versioning is to prevent accidental breaking of referencing
assemblies. If we add a new member to
Java.Interop.dllbutfail to update the version, then that permits a scenario in which
an app/lib depends on the new member, but is built against a version
missing that member. This results in runtime exceptions.
The whole reason this hasn't been a problem so far is because
Java.Interop.dllhas barely changed in years. (Plus, most usageis hidden behind other layers and libs…)
However, I want this to change: #936 and
jonpryor/java.interop/jonp-registration-scope both add new public
API to
Java.Interop.dll, and there are other features andoptimizations we're considering that would also require API changes.
A policy of "no changes" isn't tenable.
Thus: allow
Java.Interop.dllbuilt for .NET 6 to have a different$(Version)than the one built for .NET Standard 2.0.Fixing this was unexpectedly problematic, as commit 88d6093:
Java.Interop.BootstrapTasks.dlldoesn't need to be versioned, butother libraries do, and this change change meant that
VersionInfo.targetswas never used, which in turn meant that e.g.bin/BuildDebug/Version.propswas never created.Re-introduce
VersionInfo.targetsby "moving" it intobuild-tools/VersionInfo/VersionInfo.csproj, and addingVersionInfo.csprojtoJava.Interop.BootstrapTasks.sln.This allows the
Preparetarget to createbin/Build$(Configuration)/Version.props.This in turn requires moving
Java.Interop.BootstrapTasks.slnintotopdir, so that it can use
global.jsonand theMicrosoft.Build.NoTargetsversion entry.Next, update
Java.Interop.csprojso that$(Version)isconditional on
$(TargetFramework). This allows it to continueusing version 0.1.0.0 for .NET Standard 2.0, and begin using
6.0.200.* for .NET 6+ builds.
Update the default
$(Version)value to be 6.0.200.* instead of0.1.*.0, matching the .NET SDK for Android workload version.
Finally -- and most of the "noise" in this commit -- "cleanup and
unify" the disparate build systems. The above
$(Version)changesnecessitate updating the
make preparerule &msbuild /t:Preparetarget.
Clean this up: the
dotnet-based MSBuild environment is now ourSource Of Truth, and the
maketargets are updated to rely on thePreparetarget instead of duplicating most of the logic.Update
msbuild.mkso thatdotnet buildis used instead ofmsbuild.While cleaning up
Makefile, remove other cruft such as the explicitgcccalls to build theNativeTiminglib (we have a.csprojasof 5c756b1; use it!), and rationalize
Java.Runtime.Environment.dll.configgeneration.Rename the
<GenerateVersionFile/>task to<ReplaceFileContents/>,as that better describes what this task actually does.
Rename the
JdkInfo.JdksRootproperty toJdkInfo.JdkRoot, as thisbetter conveys actual semantics, and -- as part of "makefile cleanup"
-- stop probing for
/System/Library/JavaVirtualMachineson macOS,which removes a warning from
make prepare:(No, not is is not a valid JDK. It never was, and I now have to
believe that this has always warned.)