Example #1
0
        public MSBuildNuGetProject AddNewMSBuildProject(string projectName = null, NuGetFramework projectTargetFramework = null, string packagesConfigName = null)
        {
            var existingProject = Task.Run(async() => await GetNuGetProjectAsync(projectName));

            existingProject.Wait();
            if (existingProject.IsCompleted && existingProject.Result != null)
            {
                throw new ArgumentException("Project with " + projectName + " already exists");
            }

            var packagesFolder = PackagesFolder;

            projectName = string.IsNullOrEmpty(projectName) ? Guid.NewGuid().ToString() : projectName;
            var projectFullPath = Path.Combine(SolutionDirectory, projectName);

            Directory.CreateDirectory(projectFullPath);

            projectTargetFramework = projectTargetFramework ?? NuGetFramework.Parse("net45");
            var msBuildNuGetProjectSystem = new TestMSBuildNuGetProjectSystem(projectTargetFramework, new TestNuGetProjectContext(),
                                                                              projectFullPath, projectName);
            var msBuildNuGetProject = new MSBuildNuGetProject(msBuildNuGetProjectSystem, packagesFolder, projectFullPath);

            NuGetProjects.Add(msBuildNuGetProject);
            return(msBuildNuGetProject);
        }
Example #2
0
        public NuGetProject AddBuildIntegratedProject(string projectName = null, NuGetFramework projectTargetFramework = null)
        {
            if (GetNuGetProject(projectName) != null)
            {
                throw new ArgumentException("Project with " + projectName + " already exists");
            }

            var packagesFolder = Path.Combine(SolutionDirectory, PackagesFolder);

            projectName = string.IsNullOrEmpty(projectName) ? Guid.NewGuid().ToString() : projectName;
            var projectFullPath = Path.Combine(SolutionDirectory, projectName);

            Directory.CreateDirectory(projectFullPath);
            var projectJsonPath = Path.Combine(projectFullPath, "project.json");

            CreateConfigJson(projectJsonPath);

            projectTargetFramework = projectTargetFramework ?? NuGetFramework.Parse("net46");
            var msBuildNuGetProjectSystem = new TestMSBuildNuGetProjectSystem(projectTargetFramework, new TestNuGetProjectContext(),
                                                                              projectFullPath, projectName);

            var          projectFilePath = Path.Combine(projectFullPath, $"{msBuildNuGetProjectSystem.ProjectName}.csproj");
            NuGetProject nuGetProject    = new BuildIntegratedNuGetProject(projectJsonPath, projectFilePath, msBuildNuGetProjectSystem);

            NuGetProjects.Add(nuGetProject);
            return(nuGetProject);
        }
Example #3
0
        public NuGetProject AddBuildIntegratedProject(string projectName = null, NuGetFramework projectTargetFramework = null, JObject json = null)
        {
            var existingProject = Task.Run(async() => await GetNuGetProjectAsync(projectName));

            existingProject.Wait();
            if (existingProject.IsCompleted && existingProject.Result != null)
            {
                throw new ArgumentException("Project with " + projectName + " already exists");
            }

            projectName = string.IsNullOrEmpty(projectName) ? Guid.NewGuid().ToString() : projectName;
            var projectFullPath = Path.Combine(SolutionDirectory, projectName);

            Directory.CreateDirectory(projectFullPath);

            var projectJsonPath = Path.Combine(projectFullPath, "project.json");

            CreateConfigJson(projectJsonPath, json?.ToString() ?? BasicConfig.ToString());

            projectTargetFramework = projectTargetFramework ?? NuGetFramework.Parse("net46");
            var msBuildNuGetProjectSystem = new TestMSBuildNuGetProjectSystem(projectTargetFramework, new TestNuGetProjectContext(),
                                                                              projectFullPath, projectName);

            var          projectFilePath = Path.Combine(projectFullPath, $"{msBuildNuGetProjectSystem.ProjectName}.csproj");
            NuGetProject nuGetProject    = new ProjectJsonNuGetProject(projectJsonPath, projectFilePath);

            NuGetProjects.Add(nuGetProject);

            return(nuGetProject);
        }
 public NuGetProject GetNuGetProject(string nuGetProjectSafeName)
 {
     if (NuGetProjects.ContainsKey(nuGetProjectSafeName))
     {
         return(NuGetProjects[nuGetProjectSafeName]);
     }
     throw new ArgumentException(String.Format(Strings.NoNuGetProjectWithSpecifiedName, nuGetProjectSafeName));
 }
        public bool RemoveNuGetProject(string nuGetProjectSafeName)
        {
            if (NuGetProjects.ContainsKey(nuGetProjectSafeName))
            {
                NuGetProjects.Remove(nuGetProjectSafeName);
                return(true);
            }

            return(false);
        }
        public void AddNewNuGetProject(NuGetProject nuGetProject)
        {
            string nuGetProjectName = GetName(nuGetProject);

            if (NuGetProjects.ContainsKey(nuGetProjectName))
            {
                throw new ArgumentException(String.Format(Strings.AnotherNuGetProjectWithSameNameExistsInSolution, nuGetProjectName));
            }
            NuGetProjects.Add(nuGetProjectName, nuGetProject);
        }
        public NuGetProject AddNewMSBuildProject(string projectName = null, NuGetFramework projectTargetFramework = null, string packagesConfigName = null)
        {
            if (GetNuGetProject(projectName) != null)
            {
                throw new ArgumentException("Project with " + projectName + " already exists");
            }

            var packagesFolder = Path.Combine(SolutionDirectory, PackagesFolder);

            projectName = String.IsNullOrEmpty(projectName) ? Guid.NewGuid().ToString() : projectName;
            var projectFullPath = Path.Combine(SolutionDirectory, projectName);

            Directory.CreateDirectory(projectFullPath);
            var packagesConfigPath = Path.Combine(projectFullPath, String.IsNullOrEmpty(packagesConfigName) ? "packages.config" : packagesConfigName);

            projectTargetFramework = projectTargetFramework ?? NuGetFramework.Parse("net45");
            var msBuildNuGetProjectSystem = new TestMSBuildNuGetProjectSystem(projectTargetFramework, new TestNuGetProjectContext(),
                                                                              projectFullPath, projectName);
            NuGetProject nuGetProject = new MSBuildNuGetProject(msBuildNuGetProjectSystem, packagesFolder, packagesConfigPath);

            NuGetProjects.Add(nuGetProject);
            return(nuGetProject);
        }
Example #8
0
 public Task <IEnumerable <NuGetProject> > GetNuGetProjectsAsync()
 {
     return(Task.FromResult(NuGetProjects.AsEnumerable()));
 }
Example #9
0
 public Task <NuGetProject> GetNuGetProjectAsync(string nuGetProjectSafeName)
 {
     return(Task.FromResult(NuGetProjects.
                            Where(p => string.Equals(nuGetProjectSafeName, p.GetMetadata <string>(NuGetProjectMetadataKeys.Name), StringComparison.OrdinalIgnoreCase))
                            .FirstOrDefault()));
 }
Example #10
0
 public NuGetProject GetNuGetProject(string nuGetProjectSafeName)
 {
     return(NuGetProjects.
            Where(p => string.Equals(nuGetProjectSafeName, p.GetMetadata <string>(NuGetProjectMetadataKeys.Name), StringComparison.OrdinalIgnoreCase))
            .FirstOrDefault());
 }