Weird error while using MSBuild to get APK

senglorysenglory ✭✭Member ✭✭

Hi,

I am trying to make an APK from cmd line via this command:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" /t:SignAndroidPackage /p:Configuration=Release C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln

It starts building but ultimately finishes with this message:

C:\prj\Demo\Xamarin2\WiFiManager>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" /t:SignAndroidPackage /p:Configuration=Release C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln

Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 11/23/2018 3:56:18 PM.
Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" on node 1 (SignAndroidPackage target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (1) is building "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Android\WiFiManager.Android.csproj" (2) on node 1 (SignAndroidPackage target(s)).
RedirectMonoAndroidSdkPaths:
SOFTWARE\Xamarin\VisualStudio\15.0_15059c6d\Android
_CreatePropertiesCache:
Creating directory "obj\Release\MonoAndroid81\".
_SetLatestTargetFrameworkVersion:
Found Java SDK version 1.8.0.
Found Java SDK version 1.8.0.
_ValidateAndroidPackageProperties:
PackageName: WiFiManager.WiFiManager
PrepareForBuild:
Creating directory "bin\Release\".
Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Android\WiFiManager.Android.csproj" (2) is building "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj" (3:2) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Release\netstandard2.0\".
Creating directory "obj\Release\netstandard2.0\".
C:\Program Files\dotnet\sdk\2.1.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file 'C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj]
Done Building Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj" (default targets) -- FAILED.
Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Android\WiFiManager.Android.csproj" (2) is building "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj" (4:2) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Release\netstandard2.0\".
Creating directory "obj\Release\netstandard2.0\".
C:\Program Files\dotnet\sdk\2.1.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file 'C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj]
Done Building Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj" (default targets) -- FAILED.
Done Building Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Android\WiFiManager.Android.csproj" (SignAndroidPackage target(s)) -- FAILED.
Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (1) is building "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj" (4:3) on node 1 (SignAndroidPackage target(s)).
C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj : error MSB4057: The target "SignAndroidPackage" does not exist in the project.
Done Building Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj" (SignAndroidPackage target(s)) -- FAILED.
Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (1) is building "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj" (3:3) on node 1 (SignAndroidPackage target(s)).
C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj : error MSB4057: The target "SignAndroidPackage" does not exist in the project.
Done Building Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj" (SignAndroidPackage target(s)) -- FAILED.
Done Building Project "C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (SignAndroidPackage target(s)) -- FAILED.

Build FAILED.

"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (SignAndroidPackage target) (1) ->
"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Android\WiFiManager.Android.csproj" (SignAndroidPackage target) (2) ->
"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj" (default target) (3:2) ->
(ResolvePackageAssets target) ->
C:\Program Files\dotnet\sdk\2.1.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file 'C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj]

"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (SignAndroidPackage target) (1) ->
"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Android\WiFiManager.Android.csproj" (SignAndroidPackage target) (2) ->
"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj" (default target) (4:2) ->
C:\Program Files\dotnet\sdk\2.1.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file 'C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj]

"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (SignAndroidPackage target) (1) ->
"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj" (SignAndroidPackage target) (4:3) ->
C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager\WiFiManager.csproj : error MSB4057: The target "SignAndroidPackage" does not exist in the project.

"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.sln" (SignAndroidPackage target) (1) ->
"C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj" (SignAndroidPackage target) (3:3) ->
C:\prj\Demo\Xamarin2\WiFiManager\WiFiManager.Common\WiFiManager.Common.csproj : error MSB4057: The target "SignAndroidPackage" does not exist in the project.

0 Warning(s)
4 Error(s)

Time Elapsed 00:00:02.94

This target, however, exists in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets"

What am I doing wrong? How can I build a signed APK from cmd line?

Answers

  • BillyLiuBillyLiu Xamurai Member, Xamarin Team Xamurai

    @senglory
    Have you tried to clean your project and manually delete bin and obj folder, restart VS then rebuild your project?

  • navysparksnavysparks ✭✭ USMember ✭✭

    Any luck with this issue? This seems to happen when you try to transition older Xamarin.Forms projects to .Net standard 2.0..

Sign In or Register to comment.