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); }
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 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); }
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); }