0

I have a Powershell script that executes as a pre-build call for a Xamarin mobile app. The script changes the package name to match the build type e.g. Debug, Release.

To enable different "flavours" of the app to be created, I have written a batch file to replace the config file of the app with one matching the requested build type.

When I build from within Visual Studio, the powershell script runs as I expect and changes what I expected. However when the batch file runs I get an error message appearing:

enter image description here

Here is the content of the batch file, this was my first attempt at writing a batch file to build a code project:

@ECHO OFF
set buildVer=%1
set path=XamarinTestApp\XamarinTestApp
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319

echo %buildVer%

IF "%buildVer%"=="Release" (
goto :releaseBuild)

IF "%buildVer%"=="Test" (
goto :testBuild)

IF "%buildVer%"=="Dev" (
goto :devBuild)

:releaseBuild
set buildType=Release
copy /-y %path%\app.Release.config %path%\app.Config
goto :builder

:testBuild
set buildType=Release
copy /-y %path%\app.Test.config %path%\app.Config
goto :builder

:devBuild
set buildType=Debug
copy /-y %path%\app.Debug.config %path%\app.Config
goto :builder

:builder
call %msBuildDir%\msbuild.exe
C:\Projects\%path%\XamarinTestApp.Droid\XamarinTestApp.Droid.csproj /property:Configuration=%buildType% /target:SignAndroidPackage /verbosity:diag

I'm looking for any advice on either the error message I am getting, or some advice on how to get configurable information into my app.

Thanks.

Magoo
  • 77,302
  • 8
  • 62
  • 84
hydraneth
  • 3
  • 2

1 Answers1

0

Do not use path as user-variable. It is predefined by the system to locate executables.

Change that name to mypath - almost anything other than path.

from the prompt, use the command

set

to see a partial list of the names of variables that are set by the system

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • I have changed all path variables to mypath but I get the same error message. – hydraneth Feb 27 '17 at 08:22
  • Sadly, I'm no poweshell expert. From a few references found using Google, searching for `powershell exit 9009`, these articles seem to point to "file not found" http://stackoverflow.com/questions/1351830/what-does-exited-with-code-9009-mean-during-this-build http://stackoverflow.com/questions/22730003/msb3073-command-exited-with-code-9009 . Which file? No idea, but the `'& 'c:project...` seems to be a pointer. I'd suggest that powershell is interpreting that entire string up to `'Release'` as a filename. – Magoo Feb 27 '17 at 09:11
  • I worked out the issue, I removed the " and ' from the build string, then set both portable and android projects to use msbuild version 14, one was on 12 and one was on 4. This seems to have cleared up my issue. Thanks for the pointer. – hydraneth Feb 27 '17 at 11:18