Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an APK using MSBuild command line error (PackageForAndroid or SignAndroidPackage)

So I have been trying to create an APK in Release mode using the MSBuild command line executable.

Here is the contents of my batch file which I created:

ECHO Building DsdMobile Solution... >CON
cd "C:\Ross\DEVELOPMENT\HANDHELD\Android\Dsd Mobile MaterialDesign"

"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" DsdMobile.sln /P:Configuration=Release /v:quiet /t:Clean /nologo

"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" DsdMobile.sln /P:Configuration=Release /v:quiet /t:Rebuild,PackageForAndroid /nologo

The first line I change the directory to my solution location. Next, I do a Clean

Last, I do a Rebuild and PackageForAndroid (which I am expecting a ...apk file in my bin release folder. An apk is never created and I get an error.

The build is successful, but I get an error:

"C:Ross\Development\Handheld\Android\Dsd Mobile MaterialDesign\DsdMobile.sln.metaproj : error MSB4057: The target "PackageForAndroid" does not exists in the project. [C:\Ross\DEVELOPMENT\HANDHELD\Android\Dsd Mobile MaterialDesign\DsdMobile.sln]

I have also tried to use SignAndroidPackage's :t/ parameter, but this also fails with the same error:

"C:Ross\Development\Handheld\Android\Dsd Mobile MaterialDesign\DsdMobile.sln.metaproj : error MSB4057: The target "SignAndroidPackage" does not exists in the project. [C:\Ross\DEVELOPMENT\HANDHELD\Android\Dsd Mobile MaterialDesign\DsdMobile.sln]

The resource I have been using was from a PowerShell script:

https://gist.github.com/postb99/8319234

like image 883
Austin Phillips Avatar asked Dec 02 '22 11:12

Austin Phillips


2 Answers

Try building the Android csproj file instead of the solution file.

like image 103
ultravelocity Avatar answered May 19 '23 19:05

ultravelocity


This works just fine for me from Visual Studio 2017 and 2019 command line prompts:

msbuild /t:SignAndroidPackage /p:Configuration=Release Application.Android.csproj

As already noted, build the csproj not the solution.

like image 22
Jahmic Avatar answered May 19 '23 19:05

Jahmic