Skip to content

Conversation

@dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Aug 26, 2021

Our previous attempt to use GitInfo to generate Version information did not go as planned. It turns out that old style projects do NOT support the GenerateAssemblyInfo Property. As such the version information never gets generated.
As a result when we built the Xamarin.Android version of Java.Interop it never included version information and resulted in errors such as.

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 addition to this , we were generating the version data on EVERY build. It could be optimised by only generating the required
data on the first build. Or in this case the Prepare step.

This Pr introduces system when a Version.props file gets generated during the Prepare step and then that file is
imported into all the sub projects. We also have a system to make sure that for legacy projects the GenerateAssemblyInfo
actually works.

@dellis1972 dellis1972 changed the title GitInfo Take Two [WIP] [build] Use GitInfo to Generate Version information. Aug 26, 2021
@dellis1972 dellis1972 marked this pull request as ready for review August 26, 2021 23:20
@dellis1972 dellis1972 requested review from jonpryor and jpobst August 26, 2021 23:21
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Aug 27, 2021
@jonpryor
Copy link
Contributor

xamarin-android PR: dotnet/android#6241

@jonpryor
Copy link
Contributor

Not sure if related, but Windows failed to build: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=5141732&view=logs&jobId=cac0e8d3-0ef5-5d2b-b57e-e8fde7204df3&j=cac0e8d3-0ef5-5d2b-b57e-e8fde7204df3&t=d0eaacf3-179f-5217-7519-cd03bc45e5e4

CSC : error CS2001: Source file 'C:\…\src\Microsoft.Android.Sdk.ILLink\..\Xamarin.Android.Build.Tasks\obj\Release\Profile.g.cs' could not be found.

@jonathanpeppers
Copy link
Member

I think the actual error is:

(BuildVersionInfo_g_cs target) -> 
  C:\a\_work\1\s\external\Java.Interop\src\Java.Interop\Directory.Build.targets(44,5): error MSB4062:
  The "Java.Interop.BootstrapTasks.GenerateVersionFile" task could not be loaded from the assembly C:\a\_work\1\s\external\Java.Interop\src\Java.Interop\..\..\bin\BuildRelease\Java.Interop.BootstrapTasks.dll. Could not load file or assembly 'file:///C:\a\_work\1\s\external\Java.Interop\bin\BuildRelease\Java.Interop.BootstrapTasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
[C:\a\_work\1\s\external\Java.Interop\src\Java.Interop\Java.Interop-MonoAndroid.csproj]

@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).

@jonpryor jonpryor merged commit 3e6a623 into dotnet:main Sep 8, 2021
jpobst pushed a commit that referenced this pull request Sep 30, 2021
Context: d16b1e5
Context: b7982e4

Our previous attempt to use the [`GitInfo`][0] [NuGet Package][1] to
generate Version information in commit d16b1e5 did not go as planned.
It turns out that old-style projects do NOT support the
`$(GenerateAssemblyInfo)` MSBuild property.  As such the version
information is never generated.  As a result when we built the
Xamarin.Android version of `Java.Interop` it never includes version
information, which results in errors such as:

	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'

Additionally, we were generating the version data on EVERY build.
It could be optimized by only generating the required data on the
first build, or in this case the `make prepare` step.

Introduce a system where a `Version.props` file gets generated during
the `make prepare` step and then that file is imported into all the
sub-projects.  We also have a system to make sure that for legacy
projects the `$(GenerateAssemblyInfo)` property actually works.

[0]: https://github.com/devlooped/GitInfo
[1]: https://www.nuget.org/packages/GitInfo/2.1.2
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 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