Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 5ab319d

Browse files
committed
Fixups to get GenAPI running
GenAPI is super fickle. It doesn't like some trailing slashes in some cases, or ; instead of , as a path separator. Also, looks like the v4 project was missing some expected msbuild properties when invoked from the command line on incremental builds, so hard coded things like the intermediate output path and the v9.0 / monoandroid90 framework version which we'll need to eventually bump (maybe not since there are no more support libs?).
1 parent 1e1d34f commit 5ab319d

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

source/AndroidSupportProject.cshtml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,17 @@
168168
<Target Name="AndroidSupportLibrariesTypeForwardersGenerationWithGenAPI" BeforeTargets="Build">
169169
<Message Text="AndroidSupportLibrariesTypeForwardersGenerationWithGenAPI" ></Message>
170170
<PropertyGroup>
171-
<GenAPIPath>$(MSBuildProjectDirectory)/../../tools/microsoft.dotnet.buildtools.genapi.1.0.0-beta-00081/Microsoft.DotNet.BuildTools.GenAPI/tools/GenAPI.exe</GenAPIPath>
171+
<GenAPITargetFramework>$(TargetFramework)</GenAPITargetFramework>
172+
<GenAPITargetFramework Condition=" '$(GenAPITargetFramework)' == '' ">$(TargetFrameworks)</GenAPITargetFramework>
173+
<GenAPIPath>$(MSBuildProjectDirectory)\..\..\tools\microsoft.dotnet.buildtools.genapi.1.0.0-beta-00081\Microsoft.DotNet.BuildTools.GenAPI\tools\GenAPI.exe</GenAPIPath>
174+
175+
<GenAPIIntermediateOutputPath>bin\Release\MonoAndroid90\</GenAPIIntermediateOutputPath>
176+
177+
<GenAPILibPaths Condition=" '$(OS)' == 'Windows_NT' ">$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0,$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0</GenAPILibPaths>
178+
<GenAPILibPaths Condition=" '$(OS)' != 'Windows_NT' ">$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0,$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0</GenAPILibPaths>
179+
180+
<GenAPICommand Condition=" '$(OS)' == 'Windows_NT'">"$(GenAPIPath)"</GenAPICommand>
181+
<GenAPICommand Condition=" '$(OS)' != 'Windows_NT'">mono --runtime=v4.0.30319 "$(GenAPIPath)"</GenAPICommand>
172182
</PropertyGroup>
173183

174184
<ItemGroup>
@@ -177,10 +187,9 @@
177187
if (dep.IsProjectReference)
178188
{
179189
<GenAPIItemBase
180-
Include="../../generated/@(dep.MavenArtifact.MavenGroupId).@(dep.MavenArtifact.MavenArtifactId)/"
181-
>
182-
<GenAPIAssembly>"$(IntermediateOutputPath)/@(dep.NuGetPackageId).dll"</GenAPIAssembly>
183-
<GenAPICSCode>./Additions/@(dep.NuGetPackageId).cs</GenAPICSCode>
190+
Include="$(MSBuildProjectDirectory)\..\@(dep.MavenArtifact.MavenGroupId).@(dep.MavenArtifact.MavenArtifactId)\">
191+
<GenAPIAssembly>$(GenAPIIntermediateOutputPath)@(dep.NuGetPackageId).dll</GenAPIAssembly>
192+
<GenAPICSCode>$(MSBuildProjectDirectory)\Additions\@(dep.NuGetPackageId).cs</GenAPICSCode>
184193
</GenAPIItemBase>
185194
}
186195
}
@@ -191,9 +200,9 @@
191200
// For some reason GenAPI.exe can't handle absolute paths on mac/unix properly, so always make them relative
192201
// GenAPI.exe -libPath:$(MONOANDROID) -out:Some.generated.cs -w:TypeForwards ./relative/path/to/Assembly.dll
193202
-->
194-
<MakeDir Directories="./Additions" />
203+
<MakeDir Directories="$(MSBuildProjectDirectory)\Additions" />
195204
<Exec
196-
Command="mono $(GenAPIPath) -libPath:$(MONOANDROID) -out:%(GenAPIItemBase.GenAPICSCode) -w:TypeForwards %(GenAPIItemBase.Identity)/%(GenAPIItemBase.GenAPIAssembly) "
205+
Command="$(GenAPIPath) -libPath:&quot;$(GenAPILibPaths)&quot; -out:&quot;%(GenAPIItemBase.GenAPICSCode)&quot; -w:TypeForwards &quot;%(GenAPIItemBase.Identity)%(GenAPIItemBase.GenAPIAssembly)&quot;"
197206
/>
198207
</Target>
199208
}

0 commit comments

Comments
 (0)