简体   繁体   English

Powershell Pre-Build脚本从msbuild失败

[英]Powershell Pre-Build script failing from msbuild

I have a Powershell script that executes as a pre-build call for a Xamarin mobile app. 我有一个Powershell脚本,它作为Xamarin移动应用程序的预构建调用执行。 The script changes the package name to match the build type eg Debug, Release. 该脚本更改软件包名称以匹配构建类型,例如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. 当我在Visual Studio中构建时,powershell脚本会按预期运行并更改预期。 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. 请勿将path用作用户变量。 It is predefined by the system to locate executables. 它是系统预定义的,用于定位可执行文件。

Change that name to mypath - almost anything other than path . 将该名称更改为mypathpath以外的几乎所有名称。

from the prompt, use the command 在提示符下,使用命令

set

to see a partial list of the names of variables that are set by the system 查看系统设置的变量名称的部分列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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