MSBuild 干净目录字符串
我在 MSBuild 中有一个属性来表示 MSBuildProjectDirectory 上方的目录:
<PropertyGroup>
<BuildDir>$(MSBuildProjectDirectory)\..</PRSBuildDir>
</PropertyGroup>
然后我需要使用此属性,但我需要清理目录字符串,以便它不包含 ..
。换句话说,我需要评估 ..
,这样如果当前项目文件位于 C:\Test\Tom\MyDir
中,那么我需要一个包含该字符串的属性C:\Test\Tom
。
我问的原因是因为我正在尝试运行这样的命令:
msiexec /passive /i "D:\Build\2.3.84.40394\Deployment\..\Vendor\LogParser.msi"
但它抱怨 msi 的路径: 无法打开此安装包。验证该包是否存在并且您可以访问它,或者联系应用程序供应商以验证这是一个有效的 Windows Installer 包。
I have a property in MSBuild to represent the directory above the MSBuildProjectDirectory:
<PropertyGroup>
<BuildDir>$(MSBuildProjectDirectory)\..</PRSBuildDir>
</PropertyGroup>
I need to then use this property, but I need the directory string cleaned so that it doesn't include the ..
. In other words I need the ..
evaluated, so that if the current project file is in C:\Test\Tom\MyDir
, then I need a property containing the string C:\Test\Tom
.
The reason I'm asking is because I'm trying to run a command like this:
msiexec /passive /i "D:\Build\2.3.84.40394\Deployment\..\Vendor\LogParser.msi"
But it's complaining about the path to the msi: This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一个 ConvertToAbsolutePath 任务,有什么用吗?
There's a ConvertToAbsolutePath task, that any use?
我现在得到的最好的方法如下,但我想知道是否有更好的方法..
The best method I've got right now is below, but I was wondering if there might be a better way..
如果您想要评估通配符,则应该使用 Item 而不是 Property。
If you want to have wildcard evaluated, you should use Item instead of Property.
(删除了我的答案,因为我没有看到汤姆以完全相同的方式回答!)
顺便说一句,为什么不将 Exec 任务的“WorkingDirectory”属性设置为您实际调用 msiexec 的位置您的 MSI - 这样您就不会遇到路径长度问题
(deleted my answer as I didn't see that Tom had answered in exactly the same way!)
By the way, why don't you set the "WorkingDirectory" attribute of the Exec task where you actually call msiexec to be the location of your MSI - that way you won't run into an path length issues