Skip to content
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

Try to use GitInfo #865

Merged
merged 9 commits into from
Aug 19, 2021
Merged

Try to use GitInfo #865

merged 9 commits into from
Aug 19, 2021

Conversation

dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Aug 10, 2021

So lets' use the GitInfo NuGet Package to generate the required version information for Java.Interop.
The base version is controlled from GitInfo.txt. This is where the version should be edited.
The NuGet keeps track of the number of commits made since the GitInfo.txt was changed. So unless there is a major version
change (or you run out of numbers) there should be no need to alter the version on a regular basis.

All of the projects in the repo will then pick up the same version information was we will set the MSBuild Version property as well as the InformationalVersion. The latter will contain the git commit and branch.

@dellis1972
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dellis1972
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dellis1972 dellis1972 marked this pull request as ready for review August 13, 2021 12:35
@dellis1972 dellis1972 requested review from jpobst, jonathanpeppers and jonpryor and removed request for jpobst August 13, 2021 12:42
@dellis1972 dellis1972 marked this pull request as draft August 13, 2021 14:14
@dellis1972 dellis1972 marked this pull request as ready for review August 13, 2021 15:02
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the values made it to Java.Interop.dll:

[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: AssemblyInformationalVersion("0.1.4; git-head: 11d3136 git-branch: undefined")]

Do we need to check it doesn't say undefined after we merge?

@dellis1972
Copy link
Contributor Author

It looks like the values made it to Java.Interop.dll:

[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: AssemblyInformationalVersion("0.1.4; git-head: 11d3136 git-branch: undefined")]

Do we need to check it doesn't say undefined after we merge?

It says versioninfo_git locally. I suspect its undefined because CI does a merge commit , so its a detached head.

@jonpryor
Copy link
Member

So a question had been "why is this PR getting CS8400 errors about interpolated strings on .NET 6 P7, but other PRs aren't?"

The answer: other PRs are now failing with CS8400 errors: https://github.com/xamarin/java.interop/pull/868/checks?check_run_id=3365711885

Not sure why there was an apparent delay. :-/

jonpryor added a commit to jonpryor/java.interop that referenced this pull request Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323

.NET 6 Preview 7 introduced a compiler regression: use of
[C#6 string interpolation][0] when `$(LangVersion)` < 10.0
results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on dotnet#865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`RegisterAttr.cs`, in 3 locations.

Update `RegisterAttr.cs` to use `StringBuilder.Append()` calls
instead of string interpolation.  The resulting code is slightly
more annoying to read, but should perform better (slightly), and
avoids the CS8400 error.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
jonpryor added a commit to jonpryor/java.interop that referenced this pull request Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on dotnet#865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
jonpryor added a commit to jonpryor/java.interop that referenced this pull request Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on dotnet#865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost (System.String appHostSourceFilePath, System.String appHostDestinationFilePath, System.String appBinaryFilePath, System.Boolean windowsGraphicalUserInterface, System.String assemblyToCopyResorcesFrom, System.Boolean enableMacOSCodeSign)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False in the "offending" projects.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
jonpryor added a commit to jonpryor/java.interop that referenced this pull request Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on dotnet#865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost (System.String appHostSourceFilePath, System.String appHostDestinationFilePath, System.String appBinaryFilePath, System.Boolean windowsGraphicalUserInterface, System.String assemblyToCopyResorcesFrom, System.Boolean enableMacOSCodeSign)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
jonpryor added a commit that referenced this pull request Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on #865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost (System.String appHostSourceFilePath, System.String appHostDestinationFilePath, System.String appBinaryFilePath, System.Boolean windowsGraphicalUserInterface, System.String assemblyToCopyResorcesFrom, System.Boolean enableMacOSCodeSign)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
dellis1972 and others added 6 commits August 19, 2021 12:36
We think this was bumped to a specific preview6 version because of:

https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323

    error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

However, is it still needed?
@jonpryor
Copy link
Member

[build] Use GitInfo to generate $(Version) (#865)

Context: http://github.com/xamarin/xamarin-android/commit/2d81740cc1c708cd0474c9eac8936cd7abfc72e3
Context: https://github.com/xamarin/xamarin-android/issues/5749

In order to better support building solutions which reference both
.NET 6 and legacy projects within Visual Studio, we have begun
strong-naming all the MSBuild-related assemblies; see also ff271420.
This allows loading two different version of the "same" assembly, e.g.
`Java.Interop.Tools.Diagnostics.dll`, from two different filesystem
locations in the same AppDomain/AssemblyLoadContext.

However, strong-naming is only part of the solution.  The other part
is that, for sanity and reliability, the "two different versions of
the 'same' assembly" should *also* have different assembly *versions*.
If they have the same assembly version, are they truly different?

Update the build system by adding a `Directory.Build.targets` and
`GitInfo.txt` file so that the the [`GitInfo`][0] [NuGet Package][1]
will be used to "fully" set the `$(Version)` MSBuild property,
consisting of the major and minor version numbers contained within
`GitInfo.txt`, along with a "computed" `$(GitSemVerPatch)` value
based on the "patch version" in `GitInfo.txt`, if present, added to
the number of commits which have occurred since `GitInfo.txt` changed.

Additionally, set the `$(InformationalVersion)` MSBuild property so
that it mirrors the behavior in [`Mono.Android.dll`][2]:

	[assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.1.1; git-rev-head:2eb9ff2; git-branch:main")

Setting the `$(Version)` and `$(InformationalVersion)` MSBuild
properties also requires setting `$(GenerateAssemblyInfo)`=True.
Update `src/Java.Interop/Properties/AssemblyInfo.cs` to remove the
attributes that `$(GenerateAssemblyInfo)` will generate.

Other:

  * Centralize the `$(Company)` and `$(Copyright)` values.
  * Various whitespace changes due to `.editorconfig`.

[0]: https://github.com/devlooped/GitInfo
[1]: https://www.nuget.org/packages/GitInfo/2.1.2
[2]: https://github.com/xamarin/xamarin-android/commit/b620689ddf0214b1e38d5feab9e2ea7a653614ff

@jonpryor jonpryor merged commit d16b1e5 into dotnet:main Aug 19, 2021
jonpryor added a commit that referenced this pull request Aug 25, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on #865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost (System.String appHostSourceFilePath, System.String appHostDestinationFilePath, System.String appBinaryFilePath, System.Boolean windowsGraphicalUserInterface, System.String assemblyToCopyResorcesFrom, System.Boolean enableMacOSCodeSign)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
dellis1972 added a commit to dellis1972/java.interop that referenced this pull request Aug 26, 2021
jonpryor pushed a commit that referenced this pull request Aug 26, 2021
Context: dotnet/android#6229
Context: dotnet/android#6229 (comment)

This reverts commit d16b1e5.

The problem is `src/Java.Interop/Java.Interop-MonoAndroid.csproj`,
which is [used by the xamarin-android build][0] to create a
"MonoAndroid-profile" assembly (see also 85be94f).  In a d16b1e5
world -- one in which `src/Java.Interop/Properties/AssemblyInfo.cs`
doesn't contain an `[assembly: AssemblyVersion(…)]` custom attribute
-- for reasons not yet known, the `SetVersion` target is never run,
and/or *can't* run, when `Java.Interop-MonoAndroid.csproj` is built:

	% msbuild /v:diag Java.Interop-MonoAndroid.csproj /p:JavaInteropProfile=Net45 \
	    /p:XAInstallPrefix=…/xamarin-android/bin/Debug/lib/xamarin.android  \
	    /p:TargetFrameworkIdentifier=MonoAndroid \
	    /p:TargetFrameworkVersion=v1.0 \
	    /p:TargetFrameworkRootPath=…/xamarin-android/bin/Debug/lib/xamarin.android/xbuild-frameworks

Consequently, the "MonoAndroid-profile" `Java.Interop.dll` winds up
with *no* version set, i.e. version 0.0.0.0, which breaks everything:

	MainActivity.cs(13,3): error CS1705:
	Assembly 'Xamarin.Forms.Platform.Android' with identity 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'
	uses 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	which has a higher version than referenced assembly 'Java.Interop' with identity
	'Java.Interop, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'

In the interests of expediency -- we can't bump Java.Interop within
xamarin-android so long as d16b1e5 is in place -- revert commit
d16b1e5 so that we can un-block repo bumps.

We'll try to figure out how to properly use the `GitInfo` NuGet
package while supporting `Java.Interop-MonoAndroid.csproj` later.

[0]: https://github.com/xamarin/xamarin-android/blob/bcc315857f2cd61351ba469973043d91c902c50e/src/Mono.Android/Mono.Android.targets#L10-L35
jpobst pushed a commit that referenced this pull request Sep 30, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on #865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost (System.String appHostSourceFilePath, System.String appHostDestinationFilePath, System.String appBinaryFilePath, System.Boolean windowsGraphicalUserInterface, System.String assemblyToCopyResorcesFrom, System.Boolean enableMacOSCodeSign)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
jpobst pushed a commit that referenced this pull request Sep 30, 2021
[build] Use GitInfo to generate $(Version) (#865)

Context: http://github.com/xamarin/xamarin-android/commit/2d81740cc1c708cd0474c9eac8936cd7abfc72e3
Context: dotnet/android#5749

In order to better support building solutions which reference both
.NET 6 and legacy projects within Visual Studio, we have begun
strong-naming all the MSBuild-related assemblies; see also ff27142.
This allows loading two different version of the "same" assembly, e.g.
`Java.Interop.Tools.Diagnostics.dll`, from two different filesystem
locations in the same AppDomain/AssemblyLoadContext.

However, strong-naming is only part of the solution.  The other part
is that, for sanity and reliability, the "two different versions of
the 'same' assembly" should *also* have different assembly *versions*.
If they have the same assembly version, are they truly different?

Update the build system by adding a `Directory.Build.targets` and
`GitInfo.txt` file so that the the [`GitInfo`][0] [NuGet Package][1]
will be used to "fully" set the `$(Version)` MSBuild property,
consisting of the major and minor version numbers contained within
`GitInfo.txt`, along with a "computed" `$(GitSemVerPatch)` value
based on the "patch version" in `GitInfo.txt`, if present, added to
the number of commits which have occurred since `GitInfo.txt` changed.

Additionally, set the `$(InformationalVersion)` MSBuild property so
that it mirrors the behavior in [`Mono.Android.dll`][2]:

	[assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.1.1; git-rev-head:2eb9ff2; git-branch:main")

Setting the `$(Version)` and `$(InformationalVersion)` MSBuild
properties also requires setting `$(GenerateAssemblyInfo)`=True.
Update `src/Java.Interop/Properties/AssemblyInfo.cs` to remove the
attributes that `$(GenerateAssemblyInfo)` will generate.

Other:

  * Centralize the `$(Company)` and `$(Copyright)` values.
  * Various whitespace changes due to `.editorconfig`.

[0]: https://github.com/devlooped/GitInfo
[1]: https://www.nuget.org/packages/GitInfo/2.1.2
[2]: dotnet/android@b620689
jpobst pushed a commit that referenced this pull request Sep 30, 2021
Context: dotnet/android#6229
Context: dotnet/android#6229 (comment)

This reverts commit d16b1e5.

The problem is `src/Java.Interop/Java.Interop-MonoAndroid.csproj`,
which is [used by the xamarin-android build][0] to create a
"MonoAndroid-profile" assembly (see also 85be94f).  In a d16b1e5
world -- one in which `src/Java.Interop/Properties/AssemblyInfo.cs`
doesn't contain an `[assembly: AssemblyVersion(…)]` custom attribute
-- for reasons not yet known, the `SetVersion` target is never run,
and/or *can't* run, when `Java.Interop-MonoAndroid.csproj` is built:

	% msbuild /v:diag Java.Interop-MonoAndroid.csproj /p:JavaInteropProfile=Net45 \
	    /p:XAInstallPrefix=…/xamarin-android/bin/Debug/lib/xamarin.android  \
	    /p:TargetFrameworkIdentifier=MonoAndroid \
	    /p:TargetFrameworkVersion=v1.0 \
	    /p:TargetFrameworkRootPath=…/xamarin-android/bin/Debug/lib/xamarin.android/xbuild-frameworks

Consequently, the "MonoAndroid-profile" `Java.Interop.dll` winds up
with *no* version set, i.e. version 0.0.0.0, which breaks everything:

	MainActivity.cs(13,3): error CS1705:
	Assembly 'Xamarin.Forms.Platform.Android' with identity 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'
	uses 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	which has a higher version than referenced assembly 'Java.Interop' with identity
	'Java.Interop, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'

In the interests of expediency -- we can't bump Java.Interop within
xamarin-android so long as d16b1e5 is in place -- revert commit
d16b1e5 so that we can un-block repo bumps.

We'll try to figure out how to properly use the `GitInfo` NuGet
package while supporting `Java.Interop-MonoAndroid.csproj` later.

[0]: https://github.com/xamarin/xamarin-android/blob/bcc315857f2cd61351ba469973043d91c902c50e/src/Mono.Android/Mono.Android.targets#L10-L35
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants