/// <summary>
        /// Unlist or delete a package
        /// </summary>
        public override void RemovePackage(IPackage package)
        {
            if (package != null)
            {
                string fileName = _pathResolver.GetPackageFileName(package);

                lock (_lockObj)
                {
                    if (EnableDelisting)
                    {
                        var fullPath = _fileSystem.GetFullPath(fileName);

                        if (File.Exists(fullPath))
                        {
                            File.SetAttributes(fullPath, File.GetAttributes(fullPath) | FileAttributes.Hidden);
                        }
                        else
                        {
                            Debug.Fail("unable to find file");
                        }
                    }
                    else
                    {
                        _fileSystem.DeleteFile(fileName);
                    }

                    InvalidatePackages();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Main entry to the analyzer
        /// </summary>
        public void Analyze(string path)
        {
            string upath = FileSystem.GetFullPath(path);

            this.projectDir = FileSystem.DirectoryExists(upath) ? upath : FileSystem.GetDirectoryName(upath);
            LoadFileRecursive(upath);
        }
Example #3
0
        public SwitchFs(Keyset keyset, IFileSystem fs)
        {
            Fs     = fs;
            Keyset = keyset;

            if (fs.DirectoryExists("Nintendo"))
            {
                ContentsDir = fs.GetFullPath(Path.Combine("Nintendo", "Contents"));
                SaveDir     = fs.GetFullPath(Path.Combine("Nintendo", "save"));
            }
            else
            {
                if (fs.DirectoryExists("Contents"))
                {
                    ContentsDir = fs.GetFullPath("Contents");
                }

                if (fs.DirectoryExists("save"))
                {
                    SaveDir = fs.GetFullPath("save");
                }
            }

            if (ContentsDir == null)
            {
                throw new DirectoryNotFoundException("Could not find \"Contents\" directory");
            }

            OpenAllSaves();
            OpenAllNcas();
            ReadTitles();
            ReadControls();
            CreateApplications();
        }
Example #4
0
        public Task <Stream> OpenNuspecStreamAsync(PackageInfo package)
        {
            var nuspecPath = _pathResolver.GetManifestFilePath(package.Id, package.Version);

            _report.WriteLine(string.Format("  OPEN {0}", _fileSystem.GetFullPath(nuspecPath)));
            return(Task.FromResult <Stream>(File.OpenRead(nuspecPath)));
        }
Example #5
0
        private ServerPackage CreateServerPackage(IPackage package, bool enableDelisting)
        {
            // File names
            var packageFileName = GetPackageFileName(package.Id, package.Version);
            var hashFileName    = GetHashFileName(package.Id, package.Version);

            // File system
            var physicalFileSystem = _fileSystem as PhysicalFileSystem;

            // Build package info
            var packageDerivedData = new PackageDerivedData();

            // Read package hash
            using (var reader = new StreamReader(_fileSystem.OpenFile(hashFileName)))
            {
                packageDerivedData.PackageHash = reader.ReadToEnd().Trim();
            }

            // Read package info
            var localPackage = package as LocalPackage;

            if (physicalFileSystem != null)
            {
                // Read package info from file system
                var fileInfo = new FileInfo(_fileSystem.GetFullPath(packageFileName));
                packageDerivedData.PackageSize = fileInfo.Length;

                packageDerivedData.LastUpdated = _fileSystem.GetLastModified(packageFileName);
                packageDerivedData.Created     = _fileSystem.GetCreated(packageFileName);
                packageDerivedData.Path        = packageFileName;
                packageDerivedData.FullPath    = _fileSystem.GetFullPath(packageFileName);

                if (enableDelisting && localPackage != null)
                {
                    // hidden packages are considered delisted
                    localPackage.Listed = !fileInfo.Attributes.HasFlag(FileAttributes.Hidden);
                }
            }
            else
            {
                // Read package info from package (slower)
                using (var stream = package.GetStream())
                {
                    packageDerivedData.PackageSize = stream.Length;
                }

                packageDerivedData.LastUpdated = DateTime.MinValue;
                packageDerivedData.Created     = DateTime.MinValue;
            }

            // TODO: frameworks?

            // Build entry
            var serverPackage = new ServerPackage(package, packageDerivedData);

            serverPackage.IsAbsoluteLatestVersion = false;
            serverPackage.IsLatestVersion         = false;
            return(serverPackage);
        }
Example #6
0
 protected override IEnumerable <IPackageFile> GetFilesBase()
 {
     return(from p in GetPackageFilePaths()
            select new PhysicalPackageFile
     {
         SourcePath = _repositoryFileSystem.GetFullPath(p),
         TargetPath = GetPackageRelativePath(p)
     });
 }
Example #7
0
        /// <summary>
        /// Main entry to the analyzer
        /// </summary>
        public void Analyze(string path)
        {
            string upath = FileSystem.GetFullPath(path);

            this.projectDir = FileSystem.DirectoryExists(upath) ? upath : FileSystem.GetDirectoryName(upath);
            LoadFileRecursive(upath);
            msg("\nFinished loading files. " + CalledFunctions + " functions were called.");
            msg("Analyzing uncalled functions");
            ApplyUncalled();
        }
Example #8
0
        /// <summary>
        /// Main entry to the analyzer
        /// </summary>
        public void Analyze(string path)
        {
            string upath = FileSystem.GetFullPath(path);

            this.projectDir = FileSystem.DirectoryExists(upath) ? upath : FileSystem.GetDirectoryName(upath);
            LoadFileRecursive(upath);
            msg(Resources.FinishedLoadingFiles, CalledFunctions);
            msg(Resources.AnalyzingUncalledFunctions);
            ApplyUncalled();
        }
        private string ElementToValue(XElement element, bool isPath)
        {
            if (element == null)
            {
                return null;
            }

            // Return the optional value which if not there will be null;
            string value = element.GetOptionalAttributeValue("value");
            if (!isPath || String.IsNullOrEmpty(value))
            {
                return value;
            }
            return _fileSystem.GetFullPath(ResolvePath(Path.GetDirectoryName(ConfigFilePath), value));
        }
Example #10
0
        private static void LoadUserSpecificSettings(
            List <Settings> validSettingFiles,
            IFileSystem fileSystem,
            string configFileName)
        {
            // for the default location, allow case where file does not exist, in which case it'll end
            // up being created if needed
            Settings appDataSettings = null;

            if (configFileName == null)
            {
                // load %AppData%\NuGet\NuGet.config
                var userSettingsDir = DnuEnvironment.GetFolderPath(DnuFolderPath.UserSettingsDirectory);
                appDataSettings = ReadSettings(new PhysicalFileSystem(userSettingsDir),
                                               Constants.SettingsFileName);
            }
            else
            {
                if (!fileSystem.FileExists(configFileName))
                {
                    string message = String.Format(CultureInfo.CurrentCulture,
                                                   NuGetResources.FileDoesNotExit,
                                                   fileSystem.GetFullPath(configFileName));
                    throw new InvalidOperationException(message);
                }

                appDataSettings = ReadSettings(fileSystem, configFileName);
            }

            if (appDataSettings != null)
            {
                validSettingFiles.Add(appDataSettings);
            }
        }
Example #11
0
        public static string[] GenerateArguments(
            string[] args,
            IFileSystem fileSystem,
            IEnvironmentVariables environmentVariables)
        {
            List <string> expandedArguments = new List <string>();

            foreach (string argument in args)
            {
                if (!IsResponseFileArgument(argument))
                {
                    expandedArguments.Add(argument);
                    continue;
                }

                string responseFile = argument.Trim('"').Substring(1);

                responseFile = environmentVariables.ExpandEnvironmentVariables(responseFile);
                responseFile = fileSystem.GetFullPath(responseFile);

                string[] responseFileLines = fileSystem.ReadAllLines(responseFile);

                ExpandResponseFile(responseFileLines, expandedArguments);
            }

            return(expandedArguments.ToArray());
        }
Example #12
0
        private void EnsureManifest()
        {
            // we look for the .nuspec file at jQuery.1.4\jQuery.1.4.nuspec
            string manifestFile = Path.Combine(_packageName, _packageName + Constants.ManifestExtension);

            if (!_repositoryFileSystem.FileExists(manifestFile))
            {
                throw new InvalidOperationException(
                          String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_NotFound, _repositoryFileSystem.GetFullPath(manifestFile)));
            }

            using (Stream manifestStream = _repositoryFileSystem.OpenFile(manifestFile))
            {
                ReadManifest(manifestStream);
            }
        }
        /// <summary>
        /// Find all files in the target path whose name matches the given name filter.
        /// If the path points to a file, the method will return that file only.
        /// If the path points to a folder, the method will return all files inside that
        /// folder and its subfolders.
        /// </summary>
        /// <param name="nameFilterRegex">A Regular expression against which file names are checked (eg.  \.exe$ )</param>
        /// <param name="targetPath">The relative or absolute path to a file or a directory.
        /// </param>
        /// <returns>ALl files within the target path whose name matches the <paramref name="nameFilterRegex"/></returns>
        public IEnumerable <string> Find(string nameFilterRegex, string targetPath)
        {
            var matcher = new Regex(nameFilterRegex);
            var items   = new Queue <string>();

            items.Enqueue(fileSystem.GetFullPath(targetPath));

            while (items.Count > 0)
            {
                var item = items.Dequeue();
                if (fileSystem.FileExists(item))
                {
                    if (matcher.IsMatch(pathUtility.GetFileName(item)))
                    {
                        yield return(item);
                    }
                }
                else if (fileSystem.DirectoryExists(item))
                {
                    foreach (var child in fileSystem.GetEntries(item))
                    {
                        items.Enqueue(child);
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// Gets the types.
        /// </summary>
        /// <returns>The types.</returns>
        public IEnumerable <Type> GetTypes()
        {
            if (s_types == null)
            {
                s_types = new List <Type>(Assembly.GetExecutingAssembly().GetTypes());
                s_types.AddRange(typeof(UnityEngine.MonoBehaviour).Assembly.GetTypes());
                s_types.AddRange(typeof(UnityEngine.UI.Text).Assembly.GetTypes());
                var externalDlls = m_fs.GetFiles("*.dll");

                foreach (var dll in externalDlls)
                {
                    try
                    {
                        var assembly = m_assemblyLoader.LoadFrom(m_fs.GetFullPath(dll));
                        s_types.AddRange(assembly.GetTypes());
                    }
                    catch (ReflectionTypeLoadException ex)
                    {
                        var loaderMsg = new StringBuilder();

                        foreach (var l in ex.LoaderExceptions)
                        {
                            loaderMsg.AppendFormat("{0}:{1}", l.GetType().Name, l.Message);
                            loaderMsg.AppendLine();
                        }

                        throw new InvalidOperationException(
                                  "Error trying to load assembly '{0}':{1}. LoaderExceptions: {2}".With(dll, ex.Message, loaderMsg),
                                  ex);
                    }
                }
            }

            return(s_types);
        }
Example #15
0
        public MySQL(string ip, string user, string password, string database, IFileSystem disk)
        {
            myConnectionString = "server=" + ip + ";uid=" + user + ";pwd=" + password + ";database=" + database + ";useCompression=true;ConnectionTimeout=28880;DefaultCommandTimeout=28880;";

            this.path = disk.GetFullPath().Replace("\\", "/");
            this.disk = disk;
        }
Example #16
0
        public MySQL(string ip, string user, string password, string database, IFileSystem disk)
        {
            myConnectionString = "server=" + ip + ";uid=" + user + ";pwd=" + password + ";database=" + database + ";useCompression=true;ConnectionTimeout=28880;DefaultCommandTimeout=28880;";

            this.path = disk.GetFullPath().Replace("\\", "/");
            this.disk = disk;
        }
        public virtual void ParseFile(string path, FileParserContext context)
        {
            Guard.AgainstNullArgument("path", path);
            Guard.AgainstNullArgument("context", context);

            var fullPath = _fileSystem.GetFullPath(path);
            var filename = Path.GetFileName(path);

            if (context.LoadedScripts.Contains(fullPath))
            {
                _logger.DebugFormat("Skipping {0} because it's already been loaded.", filename);
                return;
            }

            _logger.DebugFormat("Processing {0}...", filename);

            if (context.ScriptPath == null)
            {
                context.ScriptPath = fullPath;
            }
            else
            {
                // Add script to loaded collection before parsing to avoid loop.
                context.LoadedScripts.Add(fullPath);
            }

            var scriptLines = _fileSystem.ReadFileLines(fullPath).ToList();

            InsertLineDirective(fullPath, scriptLines);
            InDirectory(fullPath, () => ParseScript(scriptLines, context));
        }
Example #18
0
        /// <summary>
        /// Sets the stylesheet filesystem.
        /// </summary>
        /// <remarks>
        /// Be careful when using this, the root path and root url must be correct for this to work.
        /// </remarks>
        /// <param name="fileSystem">The <see cref="IFileSystem"/>.</param>
        /// <exception cref="ArgumentNullException">If the <paramref name="fileSystem"/> is <c>null</c></exception>
        /// <exception cref="InvalidOperationException">Throws exception if the StylesheetFileSystem has already been initialized.</exception>
        /// <exception cref="InvalidOperationException">Throws exception if full path can't be resolved successfully.</exception>
        public void SetStylesheetFilesystem(IFileSystem fileSystem)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException(nameof(fileSystem));
            }

            if (_stylesheetsFileSystem != null)
            {
                throw new InvalidOperationException(
                          "The StylesheetFileSystem cannot be changed when it's already been initialized.");
            }

            // Verify that _rootUrl/_rootPath is correct
            // We have to do this because there's a tight coupling
            // to the VirtualPath we get with CodeFileDisplay from the frontend.
            try
            {
                var rootPath = fileSystem.GetFullPath("/css/");
            }
            catch (UnauthorizedAccessException exception)
            {
                throw new UnauthorizedAccessException(
                          "Can't register the stylesheet filesystem, "
                          + "this is most likely caused by using a PhysicalFileSystem with an incorrect "
                          + "rootPath/rootUrl. RootPath must be <installation folder>\\wwwroot\\css"
                          + " and rootUrl must be /css", exception);
            }

            _stylesheetsFileSystem = CreateShadowWrapperInternal(fileSystem, "css");
        }
        public static string Execute(string fileParameterValue, IFileSystem fileSystem)
        {
            if (string.IsNullOrEmpty(fileParameterValue))
            {
                throw new ArgumentException(Resources.FileParameterMustBeSpecified);
            }

            if (!fileParameterValue.EndsWith(".ps1", StringComparison.OrdinalIgnoreCase))
            {
                var error = string.Format(CultureInfo.CurrentCulture,
                    Resources.PowerShellScriptFileMustBeSpecifiedFormat,
                    fileParameterValue);

                throw new ArgumentException(error);
            }

            var filePath = fileSystem.GetFullPath(fileParameterValue);
            if (!fileSystem.FileExists(filePath))
            {
                var error = string.Format(CultureInfo.CurrentCulture,
                    Resources.PowerShellScriptFileDoesNotExistFormat,
                    fileParameterValue);

                throw new ArgumentException(error);
            }

            return filePath;
        }
Example #20
0
        public Dictionary <DateTime, Dictionary <string, WorkItem> > ProcessBugDatabase(string dllPath, IEnumerable <string> dllArgs)
        {
            string path = fileSystem.GetFullPath(dllPath);
            IBugDatabaseProvider databaseProvider = bugDatabaseDllLoader.Load(path, dllArgs, webRequest);

            return(databaseProvider.Process());
        }
Example #21
0
        public IEnumerable <string> GetAllProjectFileNames(IFileSystem fileSystem, string solutionFile)
        {
            var solution          = new Solution(fileSystem, solutionFile);
            var solutionDirectory = Path.GetDirectoryName(fileSystem.GetFullPath(solutionFile));

            return(solution.Projects.Where(p => !p.IsSolutionFolder)
                   .Select(p => Path.Combine(solutionDirectory, p.RelativePath)));
        }
Example #22
0
        public IEnumerable<string> GetAllProjectFileNames(IFileSystem fileSystem, string solutionFile)
        {
            var solution = new Solution(fileSystem, solutionFile);
            var solutionDirectory = Path.GetDirectoryName(fileSystem.GetFullPath(solutionFile));

            return solution.Projects.Where(p => !p.IsSolutionFolder)
                .Select(p => Path.Combine(solutionDirectory, p.RelativePath));
        }
Example #23
0
        internal XmlNode GetNode(string pathToXmlDocument, string xPath)
        {
            XmlNode obtainedNode = OpenDocument(pathToXmlDocument).SelectSingleNode(xPath);

            if (obtainedNode == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The node by given XPath '{0}' doesn't exist in the '{1}'.", xPath, _fileSystem.GetFullPath(pathToXmlDocument)));
            }
            return(obtainedNode);
        }
        private void CopyNonSolutionFiles(string dir, List <SolutionFolder> solutionFolder)
        {
            string solutionDir       = _fileSystem.GetDirectoryName(_dte.Solution.FileName);
            string solutionDirRoot   = _fileSystem.GetFullPath(Path.Combine(solutionDir, "..\\"));
            string solutionParentDir = GetSolutionParentDir();

            CopySolutionRootDirectories(solutionDirRoot, solutionParentDir, dir);
            CopyRootFiles(solutionDirRoot, dir);
            CopySolutionSrcFiles(solutionParentDir, dir);
        }
Example #25
0
        public static ISettings ReadSettings(string solutionDir, string nugetConfigFile, IFileSystem fileSystem,
            IMachineWideSettings machineWideSettings)
        {
            // Read the solution-level settings
            var solutionSettingsFile = Path.Combine(solutionDir, NuGetConstants.NuGetSolutionSettingsFolder);
            var fullPath = fileSystem.GetFullPath(solutionSettingsFile);
            var solutionSettingsFileSystem = new PhysicalFileSystem(fullPath);

            if (nugetConfigFile != null)
            {
                nugetConfigFile = fileSystem.GetFullPath(nugetConfigFile);
            }

            var settings = Settings.LoadDefaultSettings(
                fileSystem: solutionSettingsFileSystem,
                configFileName: nugetConfigFile,
                machineWideSettings: machineWideSettings);

            return settings;
        }
Example #26
0
        public static ISettings ReadSettings(string solutionDir, string nugetConfigFile, IFileSystem fileSystem,
                                             IMachineWideSettings machineWideSettings)
        {
            // Read the solution-level settings
            var solutionSettingsFile       = Path.Combine(solutionDir, NuGetConstants.NuGetSolutionSettingsFolder);
            var fullPath                   = fileSystem.GetFullPath(solutionSettingsFile);
            var solutionSettingsFileSystem = new PhysicalFileSystem(fullPath);

            if (nugetConfigFile != null)
            {
                nugetConfigFile = fileSystem.GetFullPath(nugetConfigFile);
            }

            var settings = Settings.LoadDefaultSettings(
                fileSystem: solutionSettingsFileSystem,
                configFileName: nugetConfigFile,
                machineWideSettings: machineWideSettings);

            return(settings);
        }
 public override void CopyFile(string sourceFilePath, IFileSystem targetFileSystem, string targetFilePath, bool overwrite)
 {
     if (targetFileSystem.IsLocal)
     {
         LongPathFile.Copy(sourceFilePath, targetFilePath, overwrite);
     }
     else
     {
         File.Copy(GetFullPath(sourceFilePath), targetFileSystem.GetFullPath(targetFilePath), overwrite);
     }
 }
 public override void MoveFile(string sourceFilePath, IFileSystem targetFileSystem, string targetFilePath)
 {
     if (targetFileSystem.IsLocal)
     {
         LongPathFile.Move(sourceFilePath, targetFilePath);
     }
     else
     {
         File.Move(GetFullPath(sourceFilePath), targetFileSystem.GetFullPath(targetFilePath));
     }
 }
Example #29
0
        private string ElementToValue(XElement element, bool isPath)
        {
            if (element == null)
            {
                return(null);
            }

            // Return the optional value which if not there will be null;
            string value = element.GetOptionalAttributeValue("value");

            if (!isPath || String.IsNullOrEmpty(value))
            {
                return(value);
            }
            // if value represents a path and relative to this file path was specified,
            // append location of file
            string configDirectory = Path.GetDirectoryName(ConfigFilePath);

            return(_fileSystem.GetFullPath(Path.Combine(configDirectory, value)));
        }
Example #30
0
        internal static void CheckDirectoryExistence(IFileSystem fileSystem, string directoryPath)
        {
            Logger.Instance.Log(LogLevel.Info, "Checking '{0}' directory existence", fileSystem.GetFullPath(directoryPath));

            if (!fileSystem.DirectoryExists(directoryPath))
            {
                throw new ValidationException(string.Format(CultureInfo.InvariantCulture, "Directory '{0}' doesn't exist", fileSystem.GetFullPath(directoryPath)));
            }

            Logger.Instance.Log(LogLevel.Info, "OK");
        }
Example #31
0
        private PackageDerivedData GetPackageDerivedData(IPackage package, bool enableDelisting)
        {
            // File names
            var normalizedVersion = package.Version.ToNormalizedString();
            var packageFileName   = GetPackageFileName(package.Id, normalizedVersion);
            var hashFileName      = GetHashFileName(package.Id, normalizedVersion);

            // File system
            var physicalFileSystem = _fileSystem as PhysicalFileSystem;

            // Build package info
            var packageDerivedData = new PackageDerivedData();

            // Read package hash
            using (var reader = new StreamReader(_fileSystem.OpenFile(hashFileName)))
            {
                packageDerivedData.PackageHash = reader.ReadToEnd().Trim();
            }

            // Read package info
            var localPackage = package as LocalPackage;

            if (physicalFileSystem != null)
            {
                // Read package info from file system
                var fullPath = _fileSystem.GetFullPath(packageFileName);
                var fileInfo = new FileInfo(fullPath);
                packageDerivedData.PackageSize = fileInfo.Length;

                packageDerivedData.LastUpdated = _fileSystem.GetLastModified(packageFileName);
                packageDerivedData.Created     = _fileSystem.GetCreated(packageFileName);
                packageDerivedData.FullPath    = fullPath;

                if (enableDelisting && localPackage != null)
                {
                    // hidden packages are considered delisted
                    localPackage.Listed = !fileInfo.Attributes.HasFlag(FileAttributes.Hidden);
                }
            }
            else
            {
                // Read package info from package (slower)
                using (var stream = package.GetStream())
                {
                    packageDerivedData.PackageSize = stream.Length;
                }

                packageDerivedData.LastUpdated = DateTime.MinValue;
                packageDerivedData.Created     = DateTime.MinValue;
            }

            return(packageDerivedData);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RepositoryManager"/> class.
        /// </summary>
        /// <param name="repositoryConfig">The repository.config file to parse.</param>
        /// <param name="repositoryEnumerator">The repository enumerator.</param>
        /// <param name="fileSystem"> </param>
        /// <example>Can be a direct path to a repository.config file</example>
        ///   
        /// <example>Can be a path to a directory, which will recursively locate all contained repository.config files</example>
        public RepositoryManager(string repositoryConfig, IRepositoryEnumerator repositoryEnumerator, IFileSystem fileSystem)
        {
            Contract.Requires(fileSystem != null);
            this.fileSystem = fileSystem;

            if (fileSystem.FileExists(repositoryConfig) && repositoryConfig.EndsWith("repositories.config"))
                RepositoryConfig = new FileInfo(fileSystem.GetFullPath(repositoryConfig));
            else
                throw new ArgumentOutOfRangeException("repository");

            PackageReferenceFiles = repositoryEnumerator.GetPackageReferenceFiles(RepositoryConfig);// GetPackageReferenceFiles();
        }
Example #33
0
        /// <summary>
        /// Unlist or delete a package
        /// </summary>
        public override void RemovePackage(IPackage package)
        {
            if (package != null)
            {
                string fileName = _pathResolver.GetPackageFileName(package);

                lock (_lockObj)
                {
                    if (EnableDelisting)
                    {
                        var fullPath = _fileSystem.GetFullPath(fileName);

                        if (File.Exists(fullPath))
                        {
                            File.SetAttributes(fullPath, File.GetAttributes(fullPath) | FileAttributes.Hidden);
                            // Delisted files can still be queried, therefore not deleting persisted hashes if present.
                            // Also, no need to flip hidden attribute on these since only the one from the nupkg is queried.
                        }
                        else
                        {
                            Debug.Fail("unable to find file");
                        }
                    }
                    else
                    {
                        _fileSystem.DeleteFile(fileName);
                        if (EnablePersistNupkgHash)
                        {
                            _fileSystem.DeleteFile(GetHashFile(fileName, false));
                            _fileSystem.DeleteFile(GetHashFile(fileName, true));
                        }
                    }

                    //InvalidatePackages();

                    RemovePackageFromCache(PackageCache, package);
                }
            }
        }
Example #34
0
            public TestResolveDependencyCommand(ITeamCityClient client, IFileSystem fileSystem, IDownloadDataFlow downloadDataFlow)
                : base(client, fileSystem, downloadDataFlow)
            {
                Client     = client;
                FileSystem = fileSystem;
                Downloader = downloadDataFlow;

                DefaultConfigLocation = @"c:\projects\projectA\dependencies.config";

                FileSystem.GetWorkingDirectory().Returns(@"c:\projects\projectA");
                FileSystem.FileExists(DefaultConfigLocation).Returns(true);
                FileSystem.GetFullPath(@"src\assemblies").Returns(@"c:\projects\projectA\src\assemblies");
            }
Example #35
0
        public static void EnsureCheckedOutIfExists(this Project project, IFileSystem fileSystem, string path)
        {
            var fullPath = fileSystem.GetFullPath(path);

            if (fileSystem.FileExists(path) &&
                project.DTE.SourceControl != null &&
                project.DTE.SourceControl.IsItemUnderSCC(fullPath) &&
                !project.DTE.SourceControl.IsItemCheckedOut(fullPath))
            {
                // Check out the item
                project.DTE.SourceControl.CheckOutItem(fullPath);
            }
        }
 public PackageReferenceRepository(IFileSystem fileSystem, ISharedPackageRepository sourceRepository)
 {
     if (fileSystem == null)
     {
         throw new ArgumentNullException("fileSystem");
     }
     if (sourceRepository == null)
     {
         throw new ArgumentNullException("sourceRepository");
     }
     _packageReferenceFile = new PackageReferenceFile(fileSystem, Constants.PackageReferenceFile);
     _fullPath = fileSystem.GetFullPath(Constants.PackageReferenceFile);
     SourceRepository = sourceRepository;
 }
 private static string SafeResolveRefreshPath(IFileSystem fileSystem, string file)
 {
     string relativePath;
     try
     {
         using (var stream = fileSystem.OpenFile(file))
         {
             relativePath = stream.ReadToEnd();
         }
         return fileSystem.GetFullPath(relativePath);
     }
     catch 
     {
         // Ignore the .refresh file if it cannot be read.
     }
     return null;
 }
Example #38
0
        public UnzippedPackage(IFileSystem fileSystem, string manifestPath)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            if (String.IsNullOrEmpty(manifestPath))
            {
                throw new ArgumentNullException("manifestPath");
            }

            string manifestFullPath = fileSystem.GetFullPath(manifestPath);
            string directory = Path.GetDirectoryName(manifestFullPath);
            _fileSystem = new PhysicalFileSystem(directory);
            _manifestPath = Path.GetFileName(manifestFullPath);

            EnsureManifest();
        }
Example #39
0
        private static void LoadUserSpecificSettings(
            List<Settings> validSettingFiles,
            IFileSystem fileSystem,
            string configFileName)
        {
            // for the default location, allow case where file does not exist, in which case it'll end
            // up being created if needed
            Settings appDataSettings = null;
            if (configFileName == null)
            {
                // load %AppData%\NuGet\NuGet.config
                string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                if (!String.IsNullOrEmpty(appDataPath))
                {
                    var defaultSettingsFilePath = Path.Combine(
                        appDataPath, "NuGet", Constants.SettingsFileName);

                    // Since defaultSettingsFilePath is a full path, so it doesn't matter what value is
                    // used as root for the PhysicalFileSystem.
                    appDataSettings = ReadSettings(
                        fileSystem ?? new PhysicalFileSystem(@"c:\"),
                        defaultSettingsFilePath);
                }
            }
            else
            {
                if (!fileSystem.FileExists(configFileName))
                {
                    string message = String.Format(CultureInfo.CurrentCulture,
                        NuGetResources.FileDoesNotExit,
                        fileSystem.GetFullPath(configFileName));
                    throw new InvalidOperationException(message);
                }

                appDataSettings = ReadSettings(fileSystem, configFileName);
            }

            if (appDataSettings != null)
            {
                validSettingFiles.Add(appDataSettings);
            }
        }
Example #40
0
        private static void LoadUserSpecificSettings(
            List<Settings> validSettingFiles,
            IFileSystem fileSystem,
            string configFileName)
        {
            // for the default location, allow case where file does not exist, in which case it'll end
            // up being created if needed
            Settings appDataSettings = null;
            if (configFileName == null)
            {
                // load %AppData%\NuGet\NuGet.config
            #if DNX451
                var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            #else
                var appDataPath = Environment.GetEnvironmentVariable("APPDATA");
            #endif
                if (!String.IsNullOrEmpty(appDataPath))
                {
                    var defaultSettingsPath = Path.Combine(appDataPath, "NuGet");
                    appDataSettings = ReadSettings(new PhysicalFileSystem(defaultSettingsPath),
                        Constants.SettingsFileName);
                }
            }
            else
            {
                if (!fileSystem.FileExists(configFileName))
                {
                    string message = String.Format(CultureInfo.CurrentCulture,
                        NuGetResources.FileDoesNotExit,
                        fileSystem.GetFullPath(configFileName));
                    throw new InvalidOperationException(message);
                }

                appDataSettings = ReadSettings(fileSystem, configFileName);
            }

            if (appDataSettings != null)
            {
                validSettingFiles.Add(appDataSettings);
            }
        }
Example #41
0
        /// <summary>
        /// Gets all assembly references for a package
        /// </summary>
        private IEnumerable<IPackageAssemblyReference> GetAssemblyReferences(
            IFileSystem fileSystem, string packageId, SemanticVersion version, out string packageDirectory)
        {
            // REVIEW: do we need to search for all variations of versions here? (e.g. 1.0, 1.0.0, 1.0.0.0)
            string packageName = packageId + "." + version.ToString();
            if (fileSystem.DirectoryExists(packageName))
            {
                string libFolderPath = Path.Combine(packageName, Constants.LibDirectory);
                if (fileSystem.DirectoryExists(libFolderPath))
                {
                    packageDirectory = fileSystem.GetFullPath(packageName);
                    // TODO: SearchFilesWithinOneSubFolders seems fragile. In the event conventions in the lib directory change to allow more than one level of nesting, it would 
                    // not work. We should let VS perform a regular install instead of doing this. 
                    return Constants.AssemblyReferencesExtensions
                                    .Select(extension => "*" + extension)
                                    .SelectMany(extension => SearchFilesWithinOneSubFolders(fileSystem, libFolderPath, extension))
                                    .Select(assembly => new FileAssemblyReference(assembly.Substring(packageName.Length).Trim(Path.DirectorySeparatorChar)));
                }
            }

            packageDirectory = null;
            return Enumerable.Empty<IPackageAssemblyReference>();
        }
Example #42
0
        private static void LoadUserSpecificSettings(
            List<Settings> validSettingFiles,
            IFileSystem fileSystem,
            string configFileName)
        {
            // for the default location, allow case where file does not exist, in which case it'll end
            // up being created if needed
            Settings appDataSettings = null;
            if (configFileName == null)
            {
                // load %AppData%\NuGet\NuGet.config
                var userSettingsDir = DnuEnvironment.GetFolderPath(DnuFolderPath.UserSettingsDirectory);
                var fileName = SettingsFileNames
                    .Select(settingsFileName => Path.Combine(userSettingsDir, settingsFileName))
                    .FirstOrDefault(fileSystem.FileExists);

                if (fileName != null)
                {
                    appDataSettings = ReadSettings(
                        new PhysicalFileSystem(userSettingsDir),
                        fileName);
                }
            }
            else
            {
                if (!fileSystem.FileExists(configFileName))
                {
                    string message = String.Format(CultureInfo.CurrentCulture,
                        NuGetResources.FileDoesNotExit,
                        fileSystem.GetFullPath(configFileName));
                    throw new InvalidOperationException(message);
                }

                appDataSettings = ReadSettings(fileSystem, configFileName);
            }

            if (appDataSettings != null)
            {
                validSettingFiles.Add(appDataSettings);
            }
        }