如何找到NuGet软件包安装的可执行文件? [英] How can I find executables installed by NuGet packages?

查看:118
本文介绍了如何找到NuGet软件包安装的可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目需要打包为zip文件以进行部署.我想在构建后的步骤中创建此zip文件.

My project needs to be packaged as a zip file for deployment. I want to create this zip file in a post build step.

要实现此目的,我已经通过NuGet安装了7-Zip命令行程序包.该软件包提供了一个我想在我的后期构建步骤中调用的可执行文件.我知道我可以通过提供已安装软件包的路径来调用它,但是此路径包含软件包的版本号,因此在更新软件包时,直接引用会中断.

To achieve this I have installed a 7-Zip command line package via NuGet. This package provides an executable which I want to call in my post build step. I know that I could call it by providing the path to the installed package but this path contains the version number of the package so a direct reference will break when the package is updated.

是否有一些MSBuild变量可用于获取已安装软件包的工具路径的路径?

Is there some MSBuild variable that I could use to get the path to my installed packages' tools path?

推荐答案

我不认为有一种方法可以避免软件包路径中的版本号,但是您可以执行类似SlowCheetah nuget软件包的操作使其在开发人员机器之间更加可移植.

I don't think there's a way to avoid the version number in the path for the package, but you can do something like what the SlowCheetah nuget package does to make it more portable between developer machines, etc.

<PropertyGroup Label="SlowCheetah">
 <SlowCheetahToolsPath>$([System.IO.Path]::GetFullPath( $(MSBuildProjectDirectory)\..\packages\SlowCheetah.2.5.12\tools\))</SlowCheetahToolsPath>
 <SlowCheetah_EnableImportFromNuGet Condition=" '$(SlowCheetah_EnableImportFromNuGet)'=='' ">true</SlowCheetah_EnableImportFromNuGet>
 <SlowCheetah_NuGetImportPath Condition=" '$(SlowCheetah_NuGetImportPath)'=='' ">$([System.IO.Path]::GetFullPath( $(MSBuildProjectDirectory)\Properties\SlowCheetah\SlowCheetah.Transforms.targets ))</SlowCheetah_NuGetImportPath>
 <SlowCheetahTargets Condition=" '$(SlowCheetah_EnableImportFromNuGet)'=='true' and Exists('$(SlowCheetah_NuGetImportPath)') ">$(SlowCheetah_NuGetImportPath)</SlowCheetahTargets>
</PropertyGroup>

这篇关于如何找到NuGet软件包安装的可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆