我试图重构一个构建脚本并在一个地方指定一个路径,而不是在任何地方复制它-但是由于某种原因,我似乎无法使我的属性正常工作。
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NetworkDeploymentRoot>\\FNFS-FS01\projects%24\company\product\deployment\mobile</NetworkDeploymentRoot>
<XFVerbosity>0</XFVerbosity>
<IsSymbolUploadSupported>0</IsSymbolUploadSupported>
<IsSymbolUploadEnabled>1</IsSymbolUploadEnabled>
<CopyToNetworkShare>0</CopyToNetworkShare>
<GetAgentUploadConfirmation>0</GetAgentUploadConfirmation>
<AgentConfirmedUpload>1</AgentConfirmedUpload>
<CreateSvnBranch>0</CreateSvnBranch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Ad-Hoc' ">
<IsSymbolUploadEnabled>1</IsSymbolUploadEnabled>
<CopyToNetworkShare>1</CopyToNetworkShare>
<GetAgentUploadConfirmation>0</GetAgentUploadConfirmation>
<AgentConfirmedUpload>1</AgentConfirmedUpload>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<IsSymbolUploadEnabled>1</IsSymbolUploadEnabled>
<CopyToNetworkShare>1</CopyToNetworkShare>
<GetAgentUploadConfirmation>0</GetAgentUploadConfirmation>
<AgentConfirmedUpload>1</AgentConfirmedUpload>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'AppStore' ">
<IsSymbolUploadEnabled>1</IsSymbolUploadEnabled>
<CopyToNetworkShare>1</CopyToNetworkShare>
<GetAgentUploadConfirmation>0</GetAgentUploadConfirmation>
<AgentConfirmedUpload>1</AgentConfirmedUpload>
</PropertyGroup>
</Project>
<Import Project="myprops.props" />
<Target Name="TestTarget3" AfterTargets="CopyIpaFromMac">
<Message Importance="High" Text="AfterTarget CopyIpaFromMac" />
<Message Importance="High" Text="Test: Dollar Configuration $(Configuration)" />
<Message Importance="High" Text="Test: Dollar CopyToNetworkShare $(CopyToNetworkShare)" />
<Message Importance="High" Text="Test: Dollar XFVerbosity $(XFVerbosity)" />
<Message Importance="High" Text="Test: Dollar NetworkDeploymentRoot $(NetworkDeploymentRoot)" />
<Error Text="NetworkDeploymentRoot Property is not set" Condition="'$(NetworkDeploymentRoot)' == '' AND $(BuildIpa) == 'true'"/>
</Target>
我所有的flags属性都可以正常工作-但是路径始终显示为空。最初我有项目$,并认为我必须逃避它,但是那还是没有解决。
有人知道为什么这似乎不适用于网络共享路径吗?
答案 0 :(得分:1)
您显示的代码工作正常,这意味着问题出在您未显示的代码中:对于给定的代码,$(NetworkDeploymentRoot)
在TestTarget3中可以为空的唯一方法是,是否有其他目标使它成为空白空的。使用多个MsBuild版本对此进行了测试,以确保确实删除了AfterTargets =“ CopyIpaFromMac”部分之后,输出始终为
>> msbuild mytarget.props /t:TestTarget3 /nologo
Build started 09-Feb-19 09:12:23.
Project "mytarget.props" on node 1 (TestTarget3 target(s)).
TestTarget3:
AfterTarget CopyIpaFromMac
Test: Dollar Configuration
Test: Dollar CopyToNetworkShare 0
Test: Dollar XFVerbosity 0
Test: Dollar NetworkDeploymentRoot \\FNFS-FS01\projects$\company\product\deployment\mobile
Done Building Project "mytarget.props" (TestTarget3 target(s)).