コード例 #1
0
        protected virtual void AddAssemblies(PackageBuilder builder, IPackageDescriptor descriptor, string assemblyPath)
        {
            if (descriptor.Assemblies.Count == 0)
            {
                return;
            }
            var assemblies = new List <ManifestFile>();
            var tempPath   = System.Web.Hosting.HostingEnvironment.MapPath(this.AssemblyPath);

            if (tempPath != null)
            {
                assemblyPath = tempPath;
            }
            foreach (var path in descriptor.Assemblies)
            {
                if (string.IsNullOrWhiteSpace(path))
                {
                    continue;
                }
                var sourcePath = Path.Combine(assemblyPath, path);
                if (!File.Exists(sourcePath))
                {
                    throw new FileNotFoundException("Cannot add assembly because file cannot be found", sourcePath);
                }
                var assembly = new ManifestFile()
                {
                    Source = sourcePath,
                    Target = "lib"
                };
                assemblies.Add(assembly);
            }
            builder.PopulateFiles(assemblyPath, assemblies);
        }
コード例 #2
0
        private void AddOutputLibFiles(IEnumerable <OutputLibFile> libFiles, HashSet <string> allowedExtensions)
        {
            var targetFolders = PackTargetArgs.BuildOutputFolder;

            foreach (var file in libFiles)
            {
                var extension = Path.GetExtension(file.FinalOutputPath);

                // Only look at files we care about
                if (!allowedExtensions.Contains(extension))
                {
                    continue;
                }
                var tfm        = NuGetFramework.Parse(file.TargetFramework).GetShortFolderName();
                var targetPath = file.TargetPath;
                for (var i = 0; i < targetFolders.Length; i++)
                {
                    var packageFile = new ManifestFile()
                    {
                        Source = file.FinalOutputPath,
                        Target = IsTool ? Path.Combine(targetFolders[i], targetPath) : Path.Combine(targetFolders[i], tfm, targetPath)
                    };

                    AddFileToBuilder(packageFile);
                }
            }
        }
コード例 #3
0
        private bool AddFileToBuilder(ManifestFile packageFile)
        {
            if (!Files.Any(p => packageFile.Target.Equals(p.Target, StringComparison.CurrentCultureIgnoreCase)))
            {
                var fileExtension = Path.GetExtension(packageFile.Source);

                if (IncludeSymbols &&
                    PackArgs.SymbolPackageFormat == SymbolPackageFormat.Snupkg &&
                    !string.Equals(fileExtension, ".pdb", StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
                else
                {
                    Files.Add(packageFile);
                    return(true);
                }
            }
            else
            {
                Logger.Log(PackagingLogMessage.CreateWarning(string.Format(
                                                                 CultureInfo.CurrentCulture,
                                                                 Strings.FileNotAddedToPackage,
                                                                 packageFile.Source,
                                                                 packageFile.Target), NuGetLogCode.NU5118));
                return(false);
            }
        }
コード例 #4
0
 private void AddSourceFiles()
 {
     foreach (var sourcePath in PackTargetArgs.SourceFiles.Keys)
     {
         var projectDirectory = PackTargetArgs.SourceFiles[sourcePath];
         if (projectDirectory.EndsWith("\\"))
         {
             projectDirectory = projectDirectory.Substring(0, projectDirectory.LastIndexOf("\\"));
         }
         var    projectName = Path.GetFileName(projectDirectory);
         string targetPath  = Path.Combine(SourcesFolder, projectName);
         if (sourcePath.Contains(projectDirectory))
         {
             var relativePath = Path.GetDirectoryName(sourcePath).Replace(projectDirectory, string.Empty);
             if (relativePath.StartsWith("\\"))
             {
                 relativePath = relativePath.Substring(1, relativePath.Length - 1);
             }
             if (relativePath.EndsWith("\\"))
             {
                 relativePath = relativePath.Substring(0, relativePath.LastIndexOf("\\"));
             }
             targetPath = Path.Combine(targetPath, relativePath);
         }
         var packageFile = new ManifestFile()
         {
             Source = sourcePath,
             Target = Path.Combine(targetPath, Path.GetFileName(sourcePath))
         };
         AddFileToBuilder(packageFile);
     }
 }
コード例 #5
0
        public Form1()
        {
            if (File.Exists(RelativePath + "Client.manifest"))
            {
                m_ClientManifest = new ManifestFile(File.Open(RelativePath + "Client.manifest", FileMode.Open));
            }
            else
            {
                MessageBox.Show("Couldn't find manifest - unable to update!");
                Environment.Exit(0);
            }

            if (MessageBox.Show("Backup data before updating?", "Backup", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                FileManager.Backup(m_ClientManifest, RelativePath);
            }

            InitializeComponent();

            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);

            m_Requester = new Requester("https://dl.dropboxusercontent.com/u/257809956/PatchManifest.manifest");

            m_Requester.OnFetchedManifest += new FetchedManifestDelegate(m_Requester_OnFetchedManifest);
            m_Requester.OnTick            += new DownloadTickDelegate(m_Requester_OnTick);
            m_Requester.OnFetchedFile     += new FetchedFileDelegate(m_Requester_OnFetchedFile);
            Logger.OnMessageLogged        += new MessageLoggedDelegate(Logger_OnMessageLogged);

            m_Requester.Initialize();
        }
コード例 #6
0
        /// <summary>
        /// Checks that a manifest matches the files on disk
        /// </summary>
        /// <param name="RootDir">Root directory for relative paths in the manifest</param>
        /// <param name="Manifest">Manifest to check</param>
        /// <param name="Files">Mapping of filename to timestamp as expected in the manifest</param>
        static void CheckManifest(DirectoryReference RootDir, TempStorageManifest Manifest, Dictionary <FileReference, DateTime> Files)
        {
            if (Files.Count != Manifest.Files.Length)
            {
                throw new AutomationException("Number of files in manifest does not match");
            }
            foreach (TempStorageFile ManifestFile in Manifest.Files)
            {
                FileReference File = ManifestFile.ToFileReference(RootDir);
                if (!File.Exists())
                {
                    throw new AutomationException("File in manifest does not exist");
                }

                DateTime OriginalTime;
                if (!Files.TryGetValue(File, out OriginalTime))
                {
                    throw new AutomationException("File in manifest did not exist previously");
                }

                double DiffSeconds = (new FileInfo(File.FullName).LastWriteTimeUtc - OriginalTime).TotalSeconds;
                if (Math.Abs(DiffSeconds) > 2)
                {
                    throw new AutomationException("Incorrect timestamp for {0}", ManifestFile.RelativePath);
                }
            }
        }
コード例 #7
0
        private static void AddFileToPackage(string directoryBase, ItemLink node, List <ManifestFile> files)
        {
            // Don't add manifest if is directory

            if (node.IsDirectory)
            {
                directoryBase += "/" + node.Filename;

                foreach (var subNode in node.Children)
                {
                    AddFileToPackage(directoryBase, subNode, files);
                }
            }
            else
            {
                //if (File.Exists(node.SourceFilepath))
                {
                    var manifest = new ManifestFile();

                    manifest.Source = node.SourceFilepath;
                    {
                        var extension = Path.GetExtension(node.SourceFilepath);
                        //var filename = Path.GetFileNameWithoutExtension(node.Filename);
                        //manifest.Target = directoryBase + "/" + filename + "_ll_" + extension;
                        manifest.Target = directoryBase + "/" + node.Filename;
                    }


                    files.Add(manifest);
                }
            }
        }
コード例 #8
0
        public bool FileIsUpToDate(string directory, ManifestFile file)
        {
            if (file.Flags == ManifestFileFlag.Directory)
            {
                return(_fileSystem.Directory.Exists(Path.Join(directory, file.FileName)));
            }

            var filePath = _fileSystem.Path.Combine(directory, file.FileName);

            if (!_fileSystem.File.Exists(filePath))
            {
                return(false);
            }

            var length = _fileSystem.FileInfo.FromFileName(filePath).Length;

            if (length == 0 && file.TotalSize == 0)
            {
                return(true);
            }

            using var fileStream     = _fileSystem.FileStream.Create(filePath, FileMode.Open);
            using var bufferedStream = new BufferedStream(fileStream);
            using var sha1           = new SHA1Managed();

            var localFileHash = sha1.ComputeHash(bufferedStream);

            return(localFileHash.SequenceEqual(file.FileHash));
        }
コード例 #9
0
        private static List <ManifestFile> GetManifestFilesForDirectory(string baseFolder, string curFolder = null)
        {
            List <ManifestFile> mfs = new List <ManifestFile>();
            string folder           = curFolder ?? baseFolder;
            var    dirs             = Directory.GetFiles(folder)?.ToList();

            if (dirs == null || dirs.Count == 0)
            {
                return(mfs);
            }

            foreach (var file in dirs)
            {
                FileAttributes attr = File.GetAttributes(file);
                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    mfs.AddRange(GetManifestFilesForDirectory(baseFolder, file));
                }
                else if (!file.EndsWith(".pdb"))
                {
                    ManifestFile mf      = new ManifestFile();
                    string       relFile = file.Replace(baseFolder, string.Empty);
                    mf.Source = Path.Combine(@"lib\net45", relFile);
                    mf.Target = Path.Combine(@"lib\net45", relFile);
                    mfs.Add(mf);
                }
            }

            return(mfs);
        }
コード例 #10
0
    private ManifestEntry[] CopyChildren()
    {
        var list = new List <ManifestEntry>(Children.Count);

        for (int i = 0; i < Children.Count; i++)
        {
            var child = Children[i];
            switch (child)
            {
            case ManifestSinkDirectory s:
            case ManifestRootDirectory r:
                throw new InvalidOperationException("Unexpected manifest node.");

            case ManifestDirectory d:
                var grandChildren = d.CopyChildren();
                var newDirectory  = CreateDirectory(d.Name, grandChildren);
                list.Add(newDirectory);
                break;

            case ManifestFile f:
                var file = new ManifestFile(f.Name, f.ResourcePath);
                list.Add(file);
                break;

            default:
                throw new InvalidOperationException("Unexpected manifest node.");
            }
        }

        return(list.ToArray());
    }
コード例 #11
0
        public void ManifestSerialization()
        {
            var manifest = new Manifest();

            manifest.Metadata.Id          = "id";
            manifest.Metadata.Authors     = "author";
            manifest.Metadata.Version     = "1.0.0";
            manifest.Metadata.Description = "description";

            manifest.Files = new List <ManifestFile>();
            var file = new ManifestFile();

            file.Source = "file_source";
            file.Target = "file_target";
            manifest.Files.Add(file);

            var memoryStream = new MemoryStream();

            manifest.Save(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);

            // read the serialized manifest.
            var newManifest = Manifest.ReadFrom(memoryStream, validateSchema: true);

            Assert.Equal(newManifest.Metadata.Id, manifest.Metadata.Id);
            Assert.Equal(newManifest.Metadata.Authors, manifest.Metadata.Authors);
            Assert.Equal(newManifest.Metadata.Description, manifest.Metadata.Description);
            Assert.Equal(newManifest.Files.Count, manifest.Files.Count);
            for (int i = 0; i < newManifest.Files.Count; ++i)
            {
                Assert.Equal(newManifest.Files[i].Source, manifest.Files[i].Source);
                Assert.Equal(newManifest.Files[i].Target, manifest.Files[i].Target);
            }
        }
コード例 #12
0
 public FileWriter(MultipleFilesHandler handler, ManifestFile manifestFile, FileTarget target, ulong expectedBytes)
 {
     _handler      = handler;
     Target        = target;
     ManifestFile  = manifestFile;
     ExpectedBytes = expectedBytes;
 }
コード例 #13
0
        /// <summary>
        /// Specifies a file to be included in the package
        /// </summary>
        /// <param name="source">The location of the file or files to include. The path is relative to the NuSpec file unless an absolute path is specified. The wildcard character, *, is allowed. Using a double wildcard, **, implies a recursive directory search.</param>
        /// <param name="target">This is a relative path to the directory within the package where the source files will be placed.</param>
        /// <param name="exclude">The file or files to exclude. This is usually combined with a wildcard value in the `src` attribute. The `exclude` attribute can contain a semi-colon delimited list of files or a file pattern. Using a double wildcard, **, implies a recursive exclude pattern.</param>
        public void AddFile(string source, string target, string exclude = "")
        {
            var mf = new ManifestFile()
            {
                Exclude = exclude, Source = source, Target = target
            };

            _manifest.Files.Add(mf);
        }
コード例 #14
0
        private static void TryAppendManifestVersion(StringBuilder builder, ModContentPack modContentPack)
        {
            var manifestFile = ManifestFile.TryParse(modContentPack);

            if (manifestFile != null && manifestFile.Version != null)
            {
                builder.AppendFormat("[mv:{0}]", manifestFile.Version);
            }
        }
コード例 #15
0
 public SpecificationBuilder WithFiles(ManifestFile files)
 {
     if (files == null)
     {
         throw new ArgumentNullException(nameof(files));
     }
     Specification.Files.Add(files);
     return(this);
 }
コード例 #16
0
ファイル: Creator.cs プロジェクト: talisker77/Package.Util
        private bool CheckAssemblyAndIncludeIfReferenced(Assembly ass)
        {
            if (NuspecDefinition.IsToolsOnly)
            {
                return(true);
            }
            string fileName;
            string pbdFileName;

            if (string.IsNullOrEmpty(ass.Location))
            {
                fileName    = ass.GetName().Name + ".dll";
                pbdFileName = ass.GetName().Name + ".pbd";
            }
            else
            {
                var assFileInfo = new FileInfo(ass.Location);
                fileName    = assFileInfo.Name;
                pbdFileName = assFileInfo.Name.Replace(assFileInfo.Extension, ".pdb");
            }
            var assemblyInBuildFolder = Path.Combine(_outputPath, fileName);

            if (!File.Exists(assemblyInBuildFolder))
            {
                return(false);
            }

            if (CheckAssemblyFoundInPackagesFolders(fileName))
            {
                return(false);
            }

            var target = _libTargets[_assembly.ImageRuntimeVersion];
            var mf     = new ManifestFile
            {
                Source = assemblyInBuildFolder,
                Target = string.Format(@"lib\{0}", target)
            };

            NuspecDefinition.ManifestFiles.Add(mf);

            var pdbFullName = Path.Combine(_outputPath, pbdFileName);

            if (NuspecDefinition.IncludePdb && File.Exists(pdbFullName))
            {
                var pbd = new ManifestFile
                {
                    Source = pdbFullName,
                    Target = string.Format(@"lib\{0}", target)
                };
                NuspecDefinition.ManifestFiles.Add(pbd);
            }


            return(true);
        }
コード例 #17
0
ファイル: Support.cs プロジェクト: samtovar/AsiSupport
        private void Initialize()
        {
            Game.FadeScreenOut(0);
            GameFiber.Wait(1000);

            Log.Info("Intializing AsiSupport version " + this.Version + "...");
            Log.Info("Using PursuitLib " + typeof(Log).GetVersion());
            Log.Info("Using PursuitLib.RPH " + typeof(RPHPlugin).GetVersion());

            ResourceManager.RegisterProvider("data", new DirectoryResourceProvider(this.DataDirectory));
            this.EnsureResourcesAvailable();
            if (this.IsStopped)
            {
                return;
            }

            ManifestFile gameVersions = new ManifestFile(Path.Combine(this.DataDirectory, "Versions.manifest"));
            string       versionStr   = Game.ProductVersion.ToString();
            bool         isSteamVer   = File.Exists("steam_api64.dll");

            for (int i = 0; i < gameVersions.Entries.Count; i++)
            {
                string entry   = gameVersions.Entries[i];
                bool   isSteam = entry[0] == 's';
                string version = entry.Substring(1);

                if (isSteam == isSteamVer && versionStr == version)
                {
                    this.GameVersion = i;
                    break;
                }
            }

            this.Loader          = new AsiLoader(Path.Combine("", "AsiPlugins"));
            this.TextureManager  = new TextureManager();
            this.KeyboardManager = new KeyboardManager();
            AsiInterface.Initialize();

            Log.Info("AsiSupport initialized.");

            if (this.Config.LoadAllPluginsOnStartup)
            {
                this.Loader.LoadAllPlugins();
            }

            if (this.Config.EnableSHVDNSupport)
            {
                SHVDN.Init();
            }

            Log.Info("All scripts are loaded. Fading screen back in...");

            Game.FadeScreenIn(1000);
            this.initialized = true;
        }
コード例 #18
0
        public void CreateResFile(string output, out string resFile)
        {
            int    code;
            string mcexe = "mc.exe";

            if (!String.IsNullOrEmpty(_toolsBin))
            {
                mcexe = Path.Combine(_toolsBin, mcexe);
            }
            using (ProcessRunner mc = new ProcessRunner(mcexe, "-U", "{0}", "-r", "{1}", "-h", "{1}"))
                using (StringWriter stdio = new StringWriter())
                {
                    mc.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { stdio.WriteLine(e.Data); };
                    if (0 != (code = mc.RunFormatArgs(_mcFile, IntermediateFiles)))
                    {
                        Trace.WriteLine(stdio.ToString());
                        throw new ApplicationException(String.Format("mc.exe failed ({0:x}):\r\n{1}", code, stdio));
                    }
                }

            string rcFile = Path.Combine(IntermediateFiles, Path.ChangeExtension(Path.GetFileName(_mcFile), ".rc"));

            VersionInfo.AppendToRc(Path.GetFileName(output), rcFile);
            if (!String.IsNullOrEmpty(IconFile) && File.Exists(IconFile))
            {
                File.AppendAllText(rcFile, String.Format("\r\n1 ICON \"{0}\"\r\n", IconFile.Replace(@"\", @"\\")));
            }
            if (!String.IsNullOrEmpty(ManifestFile) && File.Exists(ManifestFile))
            {
                File.AppendAllText(rcFile, String.Format("\r\n1 24 \"{0}\"\r\n", ManifestFile.Replace(@"\", @"\\")));
            }
            if (!String.IsNullOrEmpty(ResourceScript))
            {
                File.AppendAllText(rcFile, "\r\n" + ResourceScript + "\r\n");
            }

            string rcexe = "rc.exe";

            if (!String.IsNullOrEmpty(_toolsBin))
            {
                rcexe = Path.Combine(_toolsBin, rcexe);
            }
            using (ProcessRunner rc = new ProcessRunner(rcexe, "{0}"))
                using (StringWriter stdio = new StringWriter())
                {
                    rc.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { stdio.WriteLine(e.Data); Trace.WriteLine(e.Data, rcexe); };
                    if (0 != (code = rc.RunFormatArgs(rcFile)))
                    {
                        throw new ApplicationException(String.Format("mc.exe failed ({0:x}):\r\n{1}", code, stdio));
                    }
                }

            resFile = Path.ChangeExtension(rcFile, ".res");
        }
コード例 #19
0
    public void TraversingAFile_ReturnsUnknownPath()
    {
        // Arrange
        var file = new ManifestFile("a", "a.b.c");

        // Act
        var result = file.Traverse(".");

        // Assert
        Assert.Equal(ManifestEntry.UnknownPath, result);
    }
コード例 #20
0
        private static void EntryPointResumeSession(Session previousSession)
        {
            CurrentSession = previousSession;

            IWoWRepository repository = RepositoriesManager.GetRepositoryByMfil(CurrentSession.MFil);
            ManifestFile   manifest   = ManifestFile.FromRepository(repository);

            CurrentSession.SaveSession();

            StartProcess(manifest);
        }
コード例 #21
0
        private static void EntryPointNewSession()
        {
            IWoWRepository repository = UserInputs.SelectRepository();
            ManifestFile   manifest   = ManifestFile.FromRepository(repository);
            string         locale     = UserInputs.SelectLocale(manifest);
            string         os         = UserInputs.SelectOs();

            CurrentSession = new Session(repository.GetMFilName(), locale, os);
            CurrentSession.SaveSession();

            StartProcess(manifest);
        }
コード例 #22
0
        public void ManifestFileReturnsNoValidationResultIfSourceContainsWildCardCharacters()
        {
            // Arrange
            var manifestFile = new ManifestFile { Source = @"b?n\**\*.dll", Target = @"lib" };
            var validationContext = new ValidationContext(new object(), null, null);

            // Act
            var result = manifestFile.Validate(validationContext);

            // Assert
            Assert.False(result.Any());
        }
コード例 #23
0
        public void ManifestFileReturnsNoValidationResultsIfSourceAndTargetPathAreValid()
        {
            // Arrange
            var manifestFile = new ManifestFile { Source = @"bin\release\MyLib.dll", Target = @"lib" };
            var validationContext = new ValidationContext(new object(), null, null);

            // Act
            var result = manifestFile.Validate(validationContext);

            // Assert
            Assert.False(result.Any());
        }
コード例 #24
0
        public void ManifestFileReturnsValidationResultIfTargetContainsInvalidCharacters()
        {
            // Arrange
            var manifestFile = new ManifestFile { Source = @"bin\\**\\*.dll", Target = @"lib\\|\\net40" };
            var validationContext = new ValidationContext(new object(), null, null);

            // Act
            var result = manifestFile.Validate(validationContext).ToList();

            // Assert
            Assert.Equal(1, result.Count);
            Assert.Equal(@"Target path 'lib\\|\\net40' contains invalid characters.", result.Single().ErrorMessage);
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: theor/SquirrelPackager
        private static Assembly FindAssembly(Options options, Manifest manifest)
        {
            string       id   = manifest.Metadata.Id;
            ManifestFile asmf = manifest.Files.FirstOrDefault(f => Path.GetFileName(f.Source) == id + ".exe");

            if (asmf == null)
            {
                return(null);
            }
            string fullPath = Path.Combine(Path.GetDirectoryName(options.NuSpec), asmf.Source);

            return(Assembly.ReflectionOnlyLoadFrom(fullPath));
        }
コード例 #26
0
        public void ManifestFileReturnsNoValidationResultsIfSourceAndTargetPathAreValid()
        {
            // Arrange
            var manifestFile = new ManifestFile {
                Source = @"bin\release\MyLib.dll".Replace('\\', Path.DirectorySeparatorChar), Target = @"lib"
            };

            // Act
            var result = manifestFile.Validate();

            // Assert
            Assert.False(result.Any());
        }
コード例 #27
0
        public void ManifestFileReturnsNoValidationResultIfSourceContainsWildCardCharacters()
        {
            // Arrange
            var manifestFile = new ManifestFile {
                Source = @"b?n\**\*.dll".Replace('\\', Path.DirectorySeparatorChar), Target = @"lib"
            };

            // Act
            var result = manifestFile.Validate();

            // Assert
            Assert.False(result.Any());
        }
コード例 #28
0
        private string GetDestFilePath(ManifestFile manifestFile)
        {
            string dest = String.IsNullOrEmpty(manifestFile.InstallPath) ? this.manifest.InstallRoot : manifestFile.InstallPath;

            // resolve any tokens in the base path information
            string baseDestPath = this.reservedTokenResolver.Resolve(dest, this.manifest.InstallRoot);

            baseDestPath = this.environmentalTokenResolver.Resolve(baseDestPath);

            // ensure that files get installed into the correct location if they have specific InstallPath
            // irrespective of any folder structure within the manifest file.
            return(Path.Combine(baseDestPath, String.IsNullOrEmpty(manifestFile.InstallPath) ? manifestFile.File : Path.GetFileName(manifestFile.File)));
        }
コード例 #29
0
        public void ManifestFileReturnsValidationResultIfSourceContainsInvalidCharacters()
        {
            // Arrange
            var manifestFile = new ManifestFile {
                Source = @"bin\\|\\*.dll".Replace('\\', Path.DirectorySeparatorChar), Target = @"lib"
            };

            // Act
            var result = manifestFile.Validate().ToList();

            // Assert
            Assert.Equal(1, result.Count);
            Assert.Equal(@"Source path 'bin\\|\\*.dll' contains invalid characters.".Replace('\\', Path.DirectorySeparatorChar), result.Single());
        }
コード例 #30
0
ファイル: ManifestFileTest.cs プロジェクト: hu19891110/NuGet
        public void ManifestFileReturnsNoValidationResultsIfSourceAndTargetPathAreValid()
        {
            // Arrange
            var manifestFile = new ManifestFile {
                Source = @"bin\release\MyLib.dll", Target = @"lib"
            };
            var validationContext = new ValidationContext(new object(), null, null);

            // Act
            var result = manifestFile.Validate(validationContext);

            // Assert
            Assert.False(result.Any());
        }
コード例 #31
0
ファイル: ManifestFileTest.cs プロジェクト: hu19891110/NuGet
        public void ManifestFileReturnsNoValidationResultIfSourceContainsWildCardCharacters()
        {
            // Arrange
            var manifestFile = new ManifestFile {
                Source = @"b?n\**\*.dll", Target = @"lib"
            };
            var validationContext = new ValidationContext(new object(), null, null);

            // Act
            var result = manifestFile.Validate(validationContext);

            // Assert
            Assert.False(result.Any());
        }
コード例 #32
0
        public void ManifestFileReturnsValidationResultsIfTargetPathContainsWildCardCharacters()
        {
            // Arrange
            var manifestFile = new ManifestFile {
                Source = @"bin\\**\\*.dll".Replace('\\', Path.DirectorySeparatorChar), Target = @"lib\\**\\net40".Replace('\\', Path.DirectorySeparatorChar)
            };

            // Act
            var result = manifestFile.Validate().ToList();

            // Assert
            Assert.Equal(1, result.Count);
            Assert.Equal(@"Target path 'lib\\**\\net40' contains invalid characters.".Replace('\\', Path.DirectorySeparatorChar), result.Single());
        }
コード例 #33
0
        private static void StartProcess(ManifestFile manifest)
        {
            Program.Log("Generating file list");
            IWoWRepository    repository = RepositoriesManager.GetRepositoryByMfil(CurrentSession.MFil);
            List <FileObject> files      = manifest.GenerateFileList();

            var downloader = new FileDownloader(repository, files);

            downloader.Start();
            CurrentSession.SessionCompleted = true;
            CurrentSession.SaveSession();
            CurrentSession.Destroy();
            Program.Log("Download Complete !!", ConsoleColor.Green);
        }
コード例 #34
0
        public NuspecBuilder(string assemblyName)
        {
            var file = new ManifestFile
                       {
                           Source = assemblyName + ".dll",
                           Target = "lib"
                       };

            _manifest = new Manifest
                        {
                            Metadata = new ManifestMetadata
                                       {
                                           Id = assemblyName,
                                           Title = assemblyName,
                                           Description = assemblyName
                                       },
                            Files = new List<ManifestFile> {file}
                        };

            FilePath = assemblyName + Constants.ManifestExtension;
        }
コード例 #35
0
ファイル: SerializationTest.cs プロジェクト: nhannd/Xian
		public void ProductTest()
		{
            Product theProduct = new Product
                                     {
                                         Manifest = "Manifest.xml",
                                         Name = "ClearCanvas Test",
                                         Suffix = "SP1",
                                         Version = "1.2.12011.33333"
                                     };

		    ProductManifest theManfest = new ProductManifest
		                                     {
		                                         Product = theProduct
		                                     };

		    ManifestFile theFile = new ManifestFile
		                               {
		                                   Checksum = "111",
		                                   Filename = "Test.dll",
		                                   Timestamp = DateTime.Now
		                               };

		    theManfest.Files.Add(theFile);

            ClearCanvasManifest manifest = new ClearCanvasManifest
                                               {
                                                   ProductManifest = theManfest
                                               };

		    XmlSerializer theSerializer = new XmlSerializer(typeof(ClearCanvasManifest));

            using (FileStream fs = new FileStream("ProductTest.xml", FileMode.Create))
            {
                XmlWriter writer = XmlWriter.Create(fs);
                if (writer != null)
                    theSerializer.Serialize(writer, manifest);
                fs.Flush();
                fs.Close();
            }
		}
コード例 #36
0
ファイル: ManifestTest.cs プロジェクト: sistoimenov/NuGet2
 private void AssertFile(ManifestFile expected, ManifestFile actual)
 {
     Assert.Equal(expected.Source, actual.Source);
     Assert.Equal(expected.Target, actual.Target);
     Assert.Equal(expected.Exclude, actual.Exclude);
 }
コード例 #37
0
ファイル: ManifestTest.cs プロジェクト: sistoimenov/NuGet2
        public void ManifestSerialization()
        {
            var manifest = new Manifest();
            manifest.Metadata.Id = "id";
            manifest.Metadata.Authors = "author";
            manifest.Metadata.Version = "1.0.0";
            manifest.Metadata.Description = "description";

            manifest.Files = new List<ManifestFile>();
            var file = new ManifestFile();
            file.Source = "file_source";
            file.Target = "file_target";
            manifest.Files.Add(file);

            var memoryStream = new MemoryStream();
            manifest.Save(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);

            // read the serialized manifest.
            var newManifest = Manifest.ReadFrom(memoryStream, validateSchema: true);
            Assert.Equal(newManifest.Metadata.Id, manifest.Metadata.Id);
            Assert.Equal(newManifest.Metadata.Authors, manifest.Metadata.Authors);
            Assert.Equal(newManifest.Metadata.Description, manifest.Metadata.Description);
            Assert.Equal(newManifest.Files.Count, manifest.Files.Count);
            for (int i = 0; i < newManifest.Files.Count; ++i)
            {
                Assert.Equal(newManifest.Files[i].Source, manifest.Files[i].Source);
                Assert.Equal(newManifest.Files[i].Target, manifest.Files[i].Target);
            }
        }