示例#1
0
        private void EnsureNuGetBuild(bool fromActivation)
        {
            string solutionDirectory = _solutionManager.SolutionDirectory;
            string nugetFolderPath   = Path.Combine(solutionDirectory, VsConstants.NuGetSolutionSettingsFolder);

            IFileSystem fileSystem = _fileSystemProvider.GetFileSystem(solutionDirectory);

            if (!fileSystem.DirectoryExists(VsConstants.NuGetSolutionSettingsFolder) ||
                !fileSystem.FileExists(NuGetTargetsFile))
            {
                // download NuGet.Build and NuGet.Bootstrapper packages into the .nuget folder
                IPackageRepository repository = _packageSourceProvider.GetAggregate(_packageRepositoryFactory, ignoreFailingRepositories: true);

                // Ensure we have packages before we attempt to add them.
                var installPackages = new [] { GetPackage(repository, NuGetBuildPackageName, fromActivation),
                                               GetPackage(repository, NuGetBootstrapperPackageName, fromActivation) };
                foreach (var package in installPackages)
                {
                    fileSystem.AddFiles(package.GetFiles(Constants.ToolsDirectory), VsConstants.NuGetSolutionSettingsFolder, preserveFilePath: false);
                }

                // IMPORTANT: do this BEFORE adding the .nuget folder to solution so that
                // the generated .nuget\nuget.config is included in the solution folder too.
                DisableSourceControlMode();

                // now add the .nuget folder to the solution as a solution folder.
                _dte.Solution.AddFolderToSolution(VsConstants.NuGetSolutionSettingsFolder, nugetFolderPath);
            }
        }
示例#2
0
 public VsProjectSystem(Project project, IFileSystemProvider fileSystemProvider)
     : base(project.GetFullPath())
 {
     Project         = project;
     _baseFileSystem = fileSystemProvider.GetFileSystem(project.GetFullPath());
     Debug.Assert(_baseFileSystem != null);
 }
示例#3
0
 public VsProjectSystem(Project project, IFileSystemProvider fileSystemProvider)
     : base(project.GetFullPath())
 {
     Project         = project;
     _baseFileSystem = fileSystemProvider.GetFileSystem(project.GetFullPath(), ignoreSourceControlSetting: true);
     Debug.Assert(_baseFileSystem != null);
 }
        private static HashSet <string> GetWebsiteLocalAssemblies(Project project, IFileSystemProvider projectFileSystemProvider)
        {
            var assemblies = new HashSet <string>(PathComparer.Default);
            AssemblyReferences references = project.GetAssemblyReferences();

            foreach (AssemblyReference reference in references)
            {
                // For websites only include bin assemblies
                if (reference.ReferencedProject == null &&
                    reference.ReferenceKind == AssemblyReferenceType.AssemblyReferenceBin &&
                    File.Exists(reference.FullPath))
                {
                    assemblies.Add(reference.FullPath);
                }
            }

            // For website projects, we always add .refresh files that point to the corresponding binaries in packages. In the event of bin deployed assemblies that are also GACed,
            // the ReferenceKind is not AssemblyReferenceBin. Consequently, we work around this by looking for any additional assembly declarations specified via .refresh files.
            string projectPath = project.GetFullPath();
            var    fileSystem  = projectFileSystemProvider.GetFileSystem(projectPath);

            assemblies.AddRange(fileSystem.ResolveRefreshPaths());

            return(assemblies);
        }
示例#5
0
        private void EnsureNuGetBuild(bool fromActivation)
        {
            string solutionDirectory = _solutionManager.SolutionDirectory;
            string nugetFolderPath   = Path.Combine(solutionDirectory, VsConstants.NuGetSolutionSettingsFolder);

            IFileSystem fileSystem = _fileSystemProvider.GetFileSystem(solutionDirectory);

            if (!fileSystem.DirectoryExists(VsConstants.NuGetSolutionSettingsFolder) ||
                !fileSystem.FileExists(NuGetExeFile) ||
                !fileSystem.FileExists(NuGetTargetsFile))
            {
                // download NuGet.Build and NuGet.CommandLine packages into the .nuget folder,
                // using the active package source first and fall back to other enabled package sources.
                IPackageRepository repository = CreatePackageRestoreRepository();

                var installPackages = new string[] { NuGetBuildPackageName, NuGetCommandLinePackageName };
                foreach (var packageId in installPackages)
                {
                    IPackage package = GetPackage(repository, packageId, fromActivation);
                    if (package == null)
                    {
                        throw new InvalidOperationException(
                                  String.Format(
                                      CultureInfo.CurrentCulture,
                                      VsResources.PackageRestoreDownloadPackageFailed,
                                      packageId));
                    }

                    fileSystem.AddFiles(package.GetFiles(Constants.ToolsDirectory), VsConstants.NuGetSolutionSettingsFolder, preserveFilePath: false);
                }

                // IMPORTANT: do this BEFORE adding the .nuget folder to solution so that
                // the generated .nuget\nuget.config is included in the solution folder too.
                DisableSourceControlMode();

                // now add the .nuget folder to the solution as a solution folder.
                _dte.Solution.AddFolderToSolution(VsConstants.NuGetSolutionSettingsFolder, nugetFolderPath);
            }
        }
        /// <summary>
        /// Returns the list of framework assemblies as specified in frameworklist.xml under the ReferenceAssemblies
        /// for .NETFramework. If the file is not present, an empty list is returned
        /// </summary>
        private static List<AssemblyName> GetFrameworkAssemblies(IList<string> pathToFrameworkListFiles, IFileSystemProvider fileSystemProvider)
        {
            List<AssemblyName> frameworkAssemblies = new List<AssemblyName>();
            foreach(var pathToFrameworkListFile in pathToFrameworkListFiles)
            {
                if (!String.IsNullOrEmpty(pathToFrameworkListFile))
                {
                    var fileSystemFrameworkListFile = fileSystemProvider.GetFileSystem(pathToFrameworkListFile);
                    frameworkAssemblies.AddRange(GetFrameworkAssemblies(fileSystemFrameworkListFile));
                }
            }

            return frameworkAssemblies;
        }
示例#7
0
        /// <summary>
        /// Returns the list of framework assemblies as specified in frameworklist.xml under the ReferenceAssemblies
        /// for .NETFramework. If the file is not present, an empty list is returned
        /// </summary>
        private static List <AssemblyName> GetFrameworkAssemblies(IList <string> pathToFrameworkListFiles, IFileSystemProvider fileSystemProvider)
        {
            List <AssemblyName> frameworkAssemblies = new List <AssemblyName>();

            foreach (var pathToFrameworkListFile in pathToFrameworkListFiles)
            {
                if (!String.IsNullOrEmpty(pathToFrameworkListFile))
                {
                    var fileSystemFrameworkListFile = fileSystemProvider.GetFileSystem(pathToFrameworkListFile);
                    frameworkAssemblies.AddRange(GetFrameworkAssemblies(fileSystemFrameworkListFile));
                }
            }

            return(frameworkAssemblies);
        }
 public DeleteOnRestartManager(IFileSystemProvider fileSystemProvider, IRepositorySettings repositorySettings)
     : this(() => fileSystemProvider.GetFileSystem(repositorySettings.RepositoryPath))
 {
 }
 public static IFileSystem GetFileSystem(this IFileSystemProvider provider, string path)
 {
     return(provider.GetFileSystem(path, ignoreSourceControlSetting: false));
 }
 public DeleteOnRestartManager(IFileSystemProvider fileSystemProvider, IRepositorySettings repositorySettings)
     : this(() => fileSystemProvider.GetFileSystem(repositorySettings.RepositoryPath))
 {
 }