Skip to content

Commit

Permalink
Revert "[build] Use GitInfo to generate $(Version) (#865)" (#874)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dellis1972 authored Aug 26, 2021
1 parent 9a878f2 commit b7982e4
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 34 deletions.
22 changes: 2 additions & 20 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<_OutputPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</_OutputPath>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>

<PropertyGroup>
<XlfLanguages>cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant</XlfLanguages>
<UpdateXlfOnBuild Condition="'$(RunningOnCI)' != 'true'">true</UpdateXlfOnBuild>
Expand Down Expand Up @@ -80,7 +79,7 @@
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(DotnetToolPath) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
</PropertyGroup>

<!-- Add Roslyn analyzers NuGet to all projects -->
<ItemGroup Condition=" '$(DisableRoslynAnalyzers)' != 'True' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
Expand All @@ -89,21 +88,4 @@
</PackageReference>
</ItemGroup>

<!-- GitInfo Package for Assembly Versioning -->
<ItemGroup>
<PackageReference Include="GitInfo" Version="2.1.2" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
<GitDefaultBranch>main</GitDefaultBranch>
<GitThisAssembly>false</GitThisAssembly>
</PropertyGroup>

<Target Name="SetVersion" BeforeTargets="GetAssemblyVersion;GetPackageVersion" DependsOnTargets="GitVersion">
<PropertyGroup>
<Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)</Version>
<InformationalVersion>$(Version); git-rev-head:$(GitCommit); git-branch:$(GitBranch)</InformationalVersion>
<Company>Microsoft Corporation</Company>
<Copyright>Microsoft Corporation</Copyright>
</PropertyGroup>
</Target>
</Project>
1 change: 0 additions & 1 deletion GitInfo.txt

This file was deleted.

18 changes: 9 additions & 9 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
solution: Java.Interop.sln
configuration: $(Build.Configuration)
msbuildArguments: /restore

- task: MSBuild@1
displayName: MSBuild RunNUnitTests.targets
inputs:
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
runNativeDotnetTests: true

- template: templates\fail-on-issue.yaml

- job: mac_build
displayName: Mac - Mono
pool:
Expand All @@ -114,10 +114,10 @@ jobs:
- script: make prepare CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make prepare

- script: make all CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make all

- script: |
r=0
make run-all-tests CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion) || r=$?
Expand All @@ -139,7 +139,7 @@ jobs:
SourceFolder: $(System.DefaultWorkingDirectory)
Contents: |
xatb.jar
bin.zip
bin.zip
TargetFolder: $(Build.ArtifactStagingDirectory)
condition: succeededOrFailed()

Expand All @@ -148,7 +148,7 @@ jobs:
inputs:
ArtifactName: debug
condition: succeededOrFailed()

- job: mac_dotnet_build
displayName: Mac - .NET Core
pool:
Expand All @@ -161,12 +161,12 @@ jobs:
submodules: recursive

- template: templates\install-dependencies.yaml

- script: make prepare-core CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make prepare-core

- template: templates\core-build.yaml

- template: templates\core-tests.yaml
parameters:
runNativeTests: true
Expand Down
3 changes: 3 additions & 0 deletions src/Java.Interop.Dynamic/Java.Interop.Dynamic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<AssemblyTitle>Java.Interop.Dynamic</AssemblyTitle>
<Company>Microsoft Corporation</Company>
<Copyright>Microsoft Corporation</Copyright>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
Expand Down
3 changes: 3 additions & 0 deletions src/Java.Interop.Export/Java.Interop.Export.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<AssemblyTitle>Java.Interop.Export</AssemblyTitle>
<Company>Microsoft Corporation</Company>
<Copyright>Microsoft Corporation</Copyright>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<AssemblyTitle>Java.Interop.GenericMarshaler</AssemblyTitle>
<Company>Microsoft Corporation</Company>
<Copyright>Microsoft Corporation</Copyright>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<DefineConstants>INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
<ProjectGuid>{5C0B3562-8DA0-4726-9762-75B9709ED6B7}</ProjectGuid>
<AssemblyTitle>Java.Interop.Tools.JavaSource</AssemblyTitle>
<Company>Microsoft Corporation</Company>
<Copyright>Microsoft Corporation</Copyright>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
Expand Down
1 change: 1 addition & 0 deletions src/Java.Interop/Java.Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<DefineConstants>INTEROP;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES;$(JavaInteropDefineConstants)</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
<DocumentationFile>$(ToolOutputFullPath)Java.Interop.xml</DocumentationFile>
Expand Down
8 changes: 7 additions & 1 deletion src/Java.Interop/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

[assembly: DefaultDllImportSearchPathsAttribute (DllImportSearchPath.SafeDirectories | DllImportSearchPath.AssemblyDirectory)]

[assembly: AssemblyTitle ("Java.Interop")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyCulture ("")]

[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Microsoft Corporation")]
[assembly: AssemblyCopyright ("Microsoft Corporation")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyTrademark ("Microsoft Corporation")]
[assembly: AssemblyVersion ("0.1.0.0")]
[assembly: AssemblyMetadata ("IsTrimmable", "True")]

[assembly: InternalsVisibleTo (
Expand Down
2 changes: 0 additions & 2 deletions tests/Java.Interop-Tests/Java.Interop-Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion tools/generator/generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Link>utils\XmlExtensions.cs</Link>
</Compile>
</ItemGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
Expand Down

0 comments on commit b7982e4

Please sign in to comment.