Exemplo n.º 1
0
 /// <summary>
 /// Loads the <see cref="NuGetProject"/> from the given file location, or creates a new project at the location if none exists.
 /// </summary>
 /// <param name="fileLocation"></param>
 /// <returns></returns>
 public static NuGetProject LoadFromFile(string fileLocation, string defaultPackagesDirectory = "")
 {
     if (File.Exists(fileLocation))
     {
         using (StreamReader reader = new StreamReader(File.OpenRead(fileLocation)))
         {
             var json = JsonConvert.DeserializeObject<NuGetJsonProject>(reader.ReadToEnd());
             var project = new NuGetProject(json) { _projectJsonLocation = fileLocation };
             return project;
         }
     }
     else
     {
         var project = new NuGetProject(defaultPackagesDirectory);
         project._projectJsonLocation = fileLocation;
         project.Save();
         return project;
     }
 }