public async Task <NuGetProject> TryCreateNuGetProjectAsync(IProjectAdapter projectAdapter, ProjectProviderContext context, IProjectRestoreService projectRestoreService, bool forceProjectType) { var buildProperties = projectAdapter.BuildProperties; // read MSBuild property RestoreProjectStyle, TargetFramework, and TargetFrameworks var restoreProjectStyle = await buildProperties.GetPropertyValueAsync(ProjectBuildProperties.RestoreProjectStyle); var targetFramework = await buildProperties.GetPropertyValueAsync(ProjectBuildProperties.TargetFramework); var targetFrameworks = await buildProperties.GetPropertyValueAsync(ProjectBuildProperties.TargetFrameworks); // check for RestoreProjectStyle property is set and if not set to PackageReference then return false if (!(string.IsNullOrEmpty(restoreProjectStyle) || restoreProjectStyle.Equals(PackageReference, StringComparison.OrdinalIgnoreCase))) { return(null); } // check whether TargetFramework or TargetFrameworks property is set, else return false else if (string.IsNullOrEmpty(targetFramework) && string.IsNullOrEmpty(targetFrameworks)) { return(null); } //var projectName = projectAdapter.ProjectName; //var fullProjectPath = projectAdapter.ProjectFilePath; var projectServices = new VsMSBuildProjectSystemServices(new MSBuildProjectSystem(projectAdapter, context.ProjectContext), projectAdapter); return(new NetCorePackageReferenceNuGetProject(projectAdapter, projectServices, projectRestoreService)); }
public async Task <NuGetProject> TryCreateNuGetProjectAsync(IProjectAdapter projectAdapter, ProjectProviderContext context, IProjectRestoreService projectRestoreService, bool forceProjectType) { var projectSystem = await MSBuildNuGetProjectSystemFactory.CreateMSBuildNuGetProjectSystemAsync(projectAdapter, context.ProjectContext); await projectSystem.InitializeAsync(); var projectServices = new VsMSBuildProjectSystemServices(new MSBuildProjectSystem(projectAdapter, context.ProjectContext), projectAdapter); var solutionDirectory = projectAdapter.SolutionDirectory ?? projectAdapter.ProjectDirectory; var nuGetSettings = Settings.LoadDefaultSettings(solutionDirectory); var folderNuGetProjectFullPath = PackagesFolderPathUtility.GetPackagesFolderPath(solutionDirectory, nuGetSettings); var packagesConfigFolderPath = projectAdapter.ProjectDirectory; return(new NetFrameworkNuGetProject(projectSystem, folderNuGetProjectFullPath, packagesConfigFolderPath, projectServices)); }