public NuGetProject CreateNuGetProject(EnvDTEProject envDTEProject, INuGetProjectContext nuGetProjectContext = null) { if (nuGetProjectContext == null) { nuGetProjectContext = EmptyNuGetProjectContext; } var projectK = GetProjectKProject(envDTEProject); if (projectK != null) { return(new ProjectKNuGetProject(projectK, envDTEProject.Name, envDTEProject.UniqueName)); } var msBuildNuGetProjectSystem = MSBuildNuGetProjectSystemFactory.CreateMSBuildNuGetProjectSystem(envDTEProject, nuGetProjectContext); var folderNuGetProjectFullPath = _packagesPath(); var packagesConfigFiles = EnvDTEProjectUtility.GetPackageReferenceFileFullPaths(envDTEProject); // Item1 is path to "packages.<projectName>.config". Item2 is path to "packages.config" string packagesConfigWithProjectNameFullPath = packagesConfigFiles.Item1; string packagesConfigFullPath = packagesConfigFiles.Item2; var msBuildNuGetProject = new MSBuildNuGetProject(msBuildNuGetProjectSystem, folderNuGetProjectFullPath, File.Exists(packagesConfigWithProjectNameFullPath) ? packagesConfigWithProjectNameFullPath : packagesConfigFullPath); return(msBuildNuGetProject); }
public async Task <NuGetProject> TryCreateNuGetProjectAsync( IVsProjectAdapter vsProjectAdapter, ProjectProviderContext context, bool forceProjectType) { Assumes.Present(vsProjectAdapter); Assumes.Present(context); await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); var projectSystem = await MSBuildNuGetProjectSystemFactory.CreateMSBuildNuGetProjectSystemAsync( vsProjectAdapter, context.ProjectContext); await projectSystem.InitializeProperties(); var projectServices = await CreateProjectServicesAsync(vsProjectAdapter, projectSystem); var folderNuGetProjectFullPath = context.PackagesPathFactory(); // Project folder path is the packages config folder path var packagesConfigFolderPath = vsProjectAdapter.ProjectDirectory; return(new VsMSBuildNuGetProject( vsProjectAdapter, projectSystem, folderNuGetProjectFullPath, packagesConfigFolderPath, projectServices)); }
public bool TryCreateNuGetProject( IVsProjectAdapter vsProjectAdapter, ProjectProviderContext context, bool forceProjectType, out NuGetProject result) { Assumes.Present(vsProjectAdapter); Assumes.Present(context); _threadingService.ThrowIfNotOnUIThread(); result = null; var projectSystem = MSBuildNuGetProjectSystemFactory.CreateMSBuildNuGetProjectSystem( vsProjectAdapter, context.ProjectContext); var projectServices = CreateProjectServices(vsProjectAdapter, projectSystem); var folderNuGetProjectFullPath = context.PackagesPathFactory(); // Project folder path is the packages config folder path var packagesConfigFolderPath = vsProjectAdapter.FullPath; result = new VsMSBuildNuGetProject( vsProjectAdapter, projectSystem, folderNuGetProjectFullPath, packagesConfigFolderPath, projectServices); return(result != null); }
public async Task <NuGetProject> TryCreateNuGetProjectAsync( IVsProjectAdapter vsProjectAdapter, ProjectProviderContext context, bool forceProjectType) { Assumes.Present(vsProjectAdapter); Assumes.Present(context); var projectSystem = await MSBuildNuGetProjectSystemFactory.CreateMSBuildNuGetProjectSystemAsync( vsProjectAdapter, context.ProjectContext); await projectSystem.InitializeProperties(); var projectServices = new VsMSBuildProjectSystemServices(vsProjectAdapter, projectSystem, _threadingService, _scriptExecutor); var folderNuGetProjectFullPath = context.PackagesPathFactory(); // Project folder path is the packages config folder path var packagesConfigFolderPath = await vsProjectAdapter.GetProjectDirectoryAsync(); return(new VsMSBuildNuGetProject( vsProjectAdapter, projectSystem, folderNuGetProjectFullPath, packagesConfigFolderPath, projectServices)); }
public bool TryCreateNuGetProject(EnvDTE.Project envDTEProject, ProjectSystemProviderContext context, out NuGetProject result) { if (envDTEProject == null) { throw new ArgumentNullException(nameof(envDTEProject)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } ThreadHelper.ThrowIfNotOnUIThread(); result = null; var msBuildNuGetProjectSystem = MSBuildNuGetProjectSystemFactory.CreateMSBuildNuGetProjectSystem( envDTEProject, context.ProjectContext); var isWebSite = msBuildNuGetProjectSystem is WebSiteProjectSystem; // Web sites cannot have project.json if (!isWebSite) { // Find the project file path var projectFilePath = EnvDTEProjectUtility.GetFullProjectPath(envDTEProject); if (!string.IsNullOrEmpty(projectFilePath)) { var msbuildProjectFile = new FileInfo(projectFilePath); var projectNameFromMSBuildPath = Path.GetFileNameWithoutExtension(msbuildProjectFile.Name); // Treat projects with project.json as build integrated projects // Search for projectName.project.json first, then project.json // If the name cannot be determined, search only for project.json string projectJsonPath = null; if (string.IsNullOrEmpty(projectNameFromMSBuildPath)) { projectJsonPath = Path.Combine(msbuildProjectFile.DirectoryName, ProjectJsonPathUtilities.ProjectConfigFileName); } else { projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath(msbuildProjectFile.DirectoryName, projectNameFromMSBuildPath); } if (File.Exists(projectJsonPath)) { result = new ProjectJsonBuildIntegratedProjectSystem( projectJsonPath, msbuildProjectFile.FullName, envDTEProject, EnvDTEProjectUtility.GetCustomUniqueName(envDTEProject)); } } } // Create a normal MSBuild project if no project.json was found if (result == null) { var folderNuGetProjectFullPath = context.PackagesPathFactory(); // Project folder path is the packages config folder path var packagesConfigFolderPath = EnvDTEProjectUtility.GetFullPath(envDTEProject); result = new VSMSBuildNuGetProject( envDTEProject, msBuildNuGetProjectSystem, folderNuGetProjectFullPath, packagesConfigFolderPath); } return(result != null); }