如何在Nuget的install

如何在Nuget的install

本文介绍了如何在Nuget的install.ps1中添加PreBuildEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

配置NuGet软件包以在以下情况添加构建事件已安装
我遵循 Paul的回答并完成

Configure NuGet package to add a build event when installed
I follow Paul's answer and do it

$project.Properties.Item("PreBuildEvent").Value = "your build event here"

下面是我的install.ps1

$project.Properties.Item("PreBuildEvent").Value = "IF $(ConfigurationName) == Debug IF $(PlatformName) == ARM goto DebugARM
IF $(ConfigurationName) == Debug IF $(PlatformName) == x86 goto Debugx86
IF $(ConfigurationName) == Release IF $(PlatformName) == ARM goto ReleaseARM
IF $(ConfigurationName) == Release IF $(PlatformName) == x86 goto Releasex86

:DebugARM
echo build SDK-DebugARM
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\lib\arm\debug\LibMap.dll $(ProjectDir)LibMap.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\arm\debug\AMapSDKV2Comp.dll $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\arm\debug\AMapSDKV2Comp.winmd $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.winmd /Y
exit 0

:Debugx86
echo build SDK-Debugx86
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\lib\x86\debug\LibMap.dll $(ProjectDir)LibMap.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\x86\debug\AMapSDKV2Comp.dll $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\x86\debug\AMapSDKV2Comp.winmd $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.winmd /Y
exit 0

:ReleaseARM
echo build SDK-ReleaseARM
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\lib\arm\release\LibMap.dll $(ProjectDir)LibMap.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\arm\release\AMapSDKV2Comp.dll $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\arm\release\AMapSDKV2Comp.winmd $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.winmd /Y
exit 0

:Releasex86
echo build SDK-Releasex86
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\lib\x86\release\LibMap.dll $(ProjectDir)LibMap.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\x86\release\AMapSDKV2Comp.dll $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.dll /Y
copy $(SolutionDir)packages\AMap.2.2.0\AMAP3DEngine\references\x86\release\AMapSDKV2Comp.winmd $(SolutionDir)packages\AMap.2.2.0\lib\AMapSDKV2Comp.winmd /Y
exit 0"

但是我发现在我的vs2013中,它显示为:

but i find that in my vs2013,it shows like:

好像是删除所有"$ value"

你能告诉我如何解决这个问题吗?
我希望我的install.ps1中的内容与我的vs中的预构建事件中的内容相同

Could u tell me how to solve this?
I want that content in my install.ps1 is same with content in pre build event in my vs

推荐答案

尝试使用单引号而不是双引号.

Try using single quotes instead of double quotes.

在PowerShell中,如果使用双引号,则所有变量(例如双引号内的$ SolutionDir)将被扩展并替换为变量值.在您的情况下,这些变量不存在,因此会将它们在字符串中替换为空字符串.

In PowerShell if you use double quotes then any variables (e.g. $SolutionDir) inside the double quotes will be expanded and replaced with the variable values. In your case these variables do not exist so they are replaced in the string with empty strings.

这篇关于如何在Nuget的install.ps1中添加PreBuildEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 17:56