'how to create nuspec file in specific folder?

I tried to create .nuspec file in a different folder by giving path but it is giving me error

Nuget.exe spec ..\MYDEMOFOLDER
Nuget.exe pack ..\MYDEMOFOLDER\MYPROJECT.csproj
pause

want to create MYPROJECT.nuspec in ..\MYDEMOFOLDER folder location

getting error to create nuspec file 
The package ID '..\MYDEMOFOLDER' contains invalid characters. Examples of valid package IDs in
clude 'MyPackage' and 'MyPackage.Sample'.


Solution 1:[1]

  1. navigate to the directory you want to create the file

  2. download this nuget exe in the directory

  3. cd to the directory on command line

  4. use the command "nuget spec project.csproj"

  5. check your directory for the generated nuspec file

Solution 2:[2]

  1. Generate .nupkg file using below command

nuget pack MYPROJECT.csproj

  1. change the .nupkg file extension to .zip.

  2. Open the zip you will see the .nuspec file.

Solution 3:[3]

Dotnet has quite confusing similar arguments

--output

is used for output for build = input for nuget pack

/p:OutputPath=

is used as output folder of nuget pack itself

Example:

dotnet pack -c Release -p:PackageVersion=1.2.3 YourProject.csproj --no-build --output c:\outputofbuild  /p:OutputPath=c:\outputfornuget

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Devanshu agarwal
Solution 3 Tomas Kubes