Exemplo n.º 1
0
        public async Task <NuGetProject> UpgradeProjectToPackageReferenceAsync(NuGetProject oldProject)
        {
            Assumes.Present(oldProject);

            var projectName = await GetNuGetProjectSafeNameAsync(oldProject);

            var vsProjectAdapter = await GetVsProjectAdapterAsync(projectName);

            _projectSystemCache.TryGetProjectNames(projectName, out var projectNames);

            RemoveVsProjectAdapterFromCache(projectName);

            var context = new ProjectProviderContext(
                EmptyNuGetProjectContext,
                () => PackagesFolderPathUtility.GetPackagesFolderPath(this, _settings.Value));

            var nuGetProject = await _projectSystemFactory.CreateNuGetProjectAsync <LegacyPackageReferenceProject>(
                vsProjectAdapter, context);

            var added = _projectSystemCache.AddProject(projectNames, vsProjectAdapter, nuGetProject);

            if (DefaultNuGetProjectName == null)
            {
                DefaultNuGetProjectName = projectName;
            }

            NuGetProjectUpdated?.Invoke(this, new NuGetProjectEventArgs(nuGetProject));

            return(nuGetProject);
        }
Exemplo n.º 2
0
        public async Task <NuGetProject> UpgradeProjectToPackageReferenceAsync(NuGetProject oldProject)
        {
#if VS14
            // do nothing for VS 2015 and simply return the existing NuGetProject
            if (NuGetProjectUpdated != null)
            {
                NuGetProjectUpdated(this, new NuGetProjectEventArgs(oldProject));
            }

            return(await Task.FromResult(oldProject));
#else
            Assumes.Present(oldProject);

            var projectName      = GetNuGetProjectSafeName(oldProject);
            var vsProjectAdapter = GetVsProjectAdapter(projectName);

            _projectSystemCache.TryGetProjectNames(projectName, out var projectNames);

            RemoveVsProjectAdapterFromCache(projectName);

            var context = new ProjectProviderContext(
                EmptyNuGetProjectContext,
                () => PackagesFolderPathUtility.GetPackagesFolderPath(this, _settings.Value));

            var nuGetProject = await _projectSystemFactory.CreateNuGetProjectAsync <LegacyPackageReferenceProject>(
                vsProjectAdapter, context);

            var added = _projectSystemCache.AddProject(projectNames, vsProjectAdapter, nuGetProject);

            if (DefaultNuGetProjectName == null)
            {
                DefaultNuGetProjectName = projectName;
            }

            NuGetProjectUpdated?.Invoke(this, new NuGetProjectEventArgs(nuGetProject));

            return(nuGetProject);
#endif
        }