Reputation: 5157
nuget pack C:\Users\%USERNAME%\Source\Repos\Common\Common\Common.nuspec -OutputDirectory D:\NugetFeed
The above code is what is in my nugetpack.ps1 file. It works perfectly when I directly enter my username is the path, but I need it to be able to work for multiple users. I entered the %USERNAME% username variable into the path but I get the following response:
Could not find a part of the path 'C:\Users\%USERNAME%\Source.....'.
How can I use the %USERNAME% variable in my path. I am new to PowerShell.
Upvotes: 0
Views: 199
Reputation: 10799
Environment variables in PowerShell are on the logical drive env:
, but are otherwise syntactically normal PowerShell variables. The use of %...%
is BATCH syntax. For PowerShell, use $env:varname
, e.g., $env:username
.
You may also find that you need the information in "Run Executable From PowerShell Script With Parameters".
Upvotes: 2