0

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.

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]

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.

1 Answer 1

6

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

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

Or in one line:

Split-Path (Get-Project).FileName
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.