Nuget restore command from different directory - nuget

I try to run the following nuget command ,
in the "D:\work\Development\" directory there is solution file
nuget.exe restore D:\work\Development\
I received an error
Could not find a part of the path C:\work\Development
When I copy the nuget.exe file to the directory D:\work\Development and run resotre like so
nuget.exe restore
from there it works
How can I make restore work from another directory than the one my solution is in?

What I ended up doing is using restore from with a relative path like so :
nuget.exe restore ..\

You should pass in the path to the .sln file, such as D:\work\Development\mysolution.sln or path to the packages.config file.
Please refer to this doc for how to use the nuget.exe restore command.
http://docs.nuget.org/docs/reference/command-line-reference#Restore_command

I had a similar issue getting a relative path to work, but in my case I was accessing the nuget.exe in a subfolder as well as trying to restore packages in another folder.
I realised that the restore command path is based on the directory you are running the command from, not the directory the nuget.exe file is in.
eg. If your nuget.exe file is in a Projects\.nuget subfolder, and you are in the root directory (one up from Projects), running this will restore any packages for a solution that is in the Projects subfolder.
Projects\.nuget\nuget.exe restore Projects

Related

not able to run flutter on the command line [duplicate]

I had downloaded Flutter from https://flutter.io/setup-windows/ (flutter_windows_v0.5.1-beta.zip)
in windows 10 and followed the guidelines, extracted the zip in C:\Users\M. Junaid and opened flutter-console.bat. I tried to run flutter doctor but got the following
Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly;
The to set up flutter, run the following command:
git clone -b beta https://github.com/flutter/flutter.git
Re-checked the dependencies Git and PowerShell which are correctly installed and path variable is also correct - C:\Users\M.Junaid\flutter\bin
I Tried These But Nothing Worked:
Tried to extract in different locations C:\flutter, in AppData etc.
Running flutter_console.bat as administrator.
cd flutter and then running the command
Flutter checks for a git folder, which is normally a hidden folder. If you copied and pasted the contents of the zip file, there is a good chance that you missed copying this hidden folder.
You can solve this by doing one of the following:
Unzip the folder directly to where you want Flutter, or
Copy the outer folder (flutter) to include all the hidden files inside, or
Show all hidden files before selecting them and copying.
I solved this by using this command:
git clone -b beta https://github.com/flutter/flutter.git
(Note: make sure you have git installed.)
After that, try to open flutter_console.bat and type any flutter command to check whether it is installed properly or not.
you need to run
git init
so that the .git folder can be created.
once you do that flutter doctor will work as intended.
I was having this problem even using git to download it.
The solution was to change the folder name from .github to .git
In windows I did the following.
rename .github .git
The flutter script checks whether there is a .git directory in the working directory. If this directory is not in place, then the message is seen as reported.
So double-check for the presence of this directory. If it is not there, you may need to re-clone the repository.
This mistake also raises when flutter has '!' in a file path. https://github.com/flutter/flutter/issues/26571
So you need to rename a folder with '!' in its name.
Worked for me, while other solution didn't help.
I had same issue with Flutter 1.0. I solved it by running the following command:
git clean -xfd
This deletes all existing files and re-creates them again in another folder.
In your case, you might forget some hidden files like below (Github project does have .git directory), when you copy/move extracted content from flutter_windows_v0.5.1-beta.zip to C:\Users\M. Junaid.
.cirrus.yml
.codecov.yml
.git
.gitattributes
.github
.gitignore
.idea
.pub-cache
1- delete old flutter folder sdk, unzip the fresh version
2- Open the unzip folder of flutter sdk, then check the files hidden of ".git" to be visible, by runing command of visible the files , by open termnail and cd to path of folder :
defaults write com.apple.Finder AppleShowAllFiles true

nuget.exe doesn't restore all packages

When I run:
nuget.exe restore c:\path\to\my.sln
It creates directory c:\path\to\packages, but it only restores one of 4 nuget packages used by the solution. It only restores EntityFramework.6.2.0.
When I open the same solution in Visual Studio and rebuild, then my c:\path\to\packages\ directory also contains:
EPPlus.4.5.3.1\
NPOI.2.4.1\
SharpZipLib.1.0.0\
The solution only contains a single project.
Why does nuget.exe restore not restore all packages, instead of just restoring one of them?
Is there some command line argument to retrieve non-Microsoft packages? I didn't see one in the Nuget docs.
I updated nuget,
nuget.exe restore c:\path\to\my.sln
...and that seems to have solved the issue. I was previously using version 2.X.

Is there an equivalent to Update-package -reinstall when using nuget.exe?

I don't know why. But whenever I pull code from a repo that someone else has worked on their .csproj comes with changes that don't work on my machine. In this case, I have found that:
Sometimes running Update-Package -reinstall fixed reference problems
Sometimes opening the .csproj file and then manually removing errors works
I suspect this is something to do with the reference paths defined in the .csproj file, and that the Update-package -reinstall command fixes those references relative to the local machine that the project is being built.
is there a way to replicate the Update-package -reinstall command using nuget.exe?
you need to run nuget.exe restore packages.config -PackagesDirectory <packages_directory> where packages_directory is the directory where you want your packages to be downloaded.
You can read more about the restore operation here.
I would recommend that you standardize the build steps in a shared script in your repository. For instance -
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile nuget.exe
& nuget.exe restore packages.config -PackagesDirectory packages_directory
& msbuild /t:build project.csproj

How to cloak directories in TFS command line

I want to ignore some directory while checking out code from TFS using TFS command line.
For example, say i have a TFS url path where i have two directory, namely Iteration9 and Iteration11 .
Now I want to check out from that url path such a way so that only Iteration9 gets checked out and ignore the Iteration11
So far i am following the steps,
Create a workspace named cloak_1:
./tf workspace -new -collection:http://tfsna.int.com:8080/tfs/C_Collection -login:user27#domain,password cloak_1;
Cloak the Iteration11 directory which i don't want:
./tf workfold -cloak $/Cobalt Search/Releases/1.0/Iteration11 -workspace:cloak_1 -login:user27#domain,'password';
Map the path to my local Directory:
./tf workfold -map -workspace:cloak_1 -login:user27#domain,password '$/C_Search/Releases/1.0' /tfs/TEE-CLC-10.1.0/cl-test1;
Finally get the source code:
./tf get -recursive -login:user27#domain,password /tfs/TEE-CLC-10.1.0/cl-test1;
But the cloak is not working here. i am getting both the directory in my local folder. please tell me where i am doing wrong.
You can create the workspace configuration that your want in visual studio with the UI and then clone it when you want to use it.
http://roadtoalm.com/2011/10/25/hidden-gems-in-tfspart-6-managing-workspaces-in-tfs-with-workspace-templates/

Nuget: How to copy a files to root folder without including in project

If you put any files in the Content folder of a Nuget package, during installation these files are:
Copied to the root of the target project and
Included in the project.
Is there any way to make Nuget skip action 2, i.e. to copy them but not include them in the project?
I know I can do this with a Powershell script that goes in and removes the files from the project. But I don't think that's a very robust method.
Can I achieve this without relying on Powershell?
You can try adding your contents directly in the package instead of the "contents" folder.
Files outside "contents" would be ignored by NuGet while trying to add content files.
Then you can do just the copying part using your powershell scr