简体   繁体   中英

Powershell Pre-Build script failing from msbuild

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 eg 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:

在此处输入图片说明

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM