Nuget Powershell:如何将项目文件夹传递给命令 [英] Nuget Powershell: How to pass project folder to command

查看:33
本文介绍了Nuget Powershell:如何将项目文件夹传递给命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些小的 c# 控制台应用程序,它们的路径已添加到系统路径中,因此可以在任何地方调用.因此,我可以从包管理器 (PM) 控制台运行这些应用程序.

I have some small c# console applications whose path have been added to the system path and at such can be called anywhere. Because of this, I can run these applications from the package manager (PM) console.

现在这件事是我如何将一个项目的路径传递给文档.例如.控制台应用程序之一是文档".我想执行document --path=[.Model 项目的路径]

This thing now is how do I pass a path to one of the projects to the document. E.g. one of the console applications is "document". I want to execute document --path=[path to .Model project]

鉴于该解决方案有三 (3) 个项目,其中一个处于活动状态,应如何编写命令以将其传递到活动或选定项目的路径中.

Given that the solution has three(3) projects with one active, how should the command be written so that it is passed in the path to the active or selected project.

推荐答案

NuGet 包管理器控制台提供了一个 Get-Project cmdlet 可用于返回活动项目或特定项目(如果传递了 -Name 参数).下面显示了两个示例.

The NuGet Package Manager console provides a Get-Project cmdlet that can be used to return the active project, or a particular project if the -Name parameter is passed. Two examples are shown below.

Get-Project
Get-Project -Name MyProjectName

返回的 项目对象 有一个 FileName 属性,它返回项目的文件名.然后,您可以将其传递给 Split-Path cmdlet 以获取目录.一次做这行:

The project object returned has a FileName property which returns the filename of the project. You could then pass that to the Split-Path cmdlet to get the directory. Doing this one line at a time:

$p = Get-Project
Split-Path $p.FileName

或在一行中:

Split-Path (Get-Project).FileName

这篇关于Nuget Powershell:如何将项目文件夹传递给命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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