Ejemplo n.º 1
0
        public void EnsureRelativePath()
        {
            Assert.That(QQnPath.EnsureRelativePath("c:\\tools", "c:/tools/t.txt"), Is.EqualTo("t.txt"));
            Assert.That(QQnPath.EnsureRelativePath("c:\\tools", "c:/t.txt"), Is.EqualTo("..\\t.txt"));

            Assert.That(QQnPath.EnsureRelativePath("c:\\tools", "t.txt"), Is.EqualTo("t.txt"));
            Assert.That(QQnPath.EnsureRelativePath("c:\\tools", "\\banaan\\t.txt"), Is.EqualTo("..\\banaan\\t.txt"));

            string currentDisk = Path.GetPathRoot(Environment.CurrentDirectory);
            string otherDisk;

            if (string.Equals(currentDisk, "z:\\", StringComparison.OrdinalIgnoreCase))
            {
                otherDisk = "z:\\";
            }
            else
            {
                otherDisk = "c:\\";
            }

            Assert.That(Path.Combine(otherDisk + "tools", "\\t.txt"), Is.EqualTo("\\t.txt"), "Path.Combine works like .Net 2.0");
            Assert.That(Path.GetFullPath(Path.Combine(otherDisk + "tools", "\\t.txt")), Is.EqualTo(currentDisk + "t.txt"), "Path.Combine works like .Net 2.0");
            Assert.That(QQnPath.Combine(otherDisk + "tools", "\\t.txt"), Is.EqualTo(otherDisk + "t.txt"), "QQnPath combines always relative");


            Assert.That(QQnPath.NormalizePath("c:\\", false), Is.EqualTo("c:\\"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the file.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="include">The include.</param>
        /// <param name="baseDirectory">The base directory.</param>
        /// <returns></returns>
        public TagItem AddFile(string name, string include, string baseDirectory)
        {
            baseDirectory = Path.GetFullPath(baseDirectory);
            include       = QQnPath.EnsureRelativePath(baseDirectory, include);

            TagItem item = new TagItem(name, include);

            item.Keys.Add("FileOrigin", baseDirectory);

            Add(item);

            return(item);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Ensures the specified key is relative
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        protected virtual string EnsureRelative(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            if (string.IsNullOrEmpty(BaseDirectory))
            {
                return(Path.GetFullPath(key));
            }
            else
            {
                return(QQnPath.EnsureRelativePath(BaseDirectory, key));
            }
        }
Ejemplo n.º 4
0
        public Pack CreateDefinition(TBLogFile file)
        {
            BuildOrigin myOrigin = null;

            foreach (BuildOrigin bo in BuildOrigins)
            {
                if (bo.LogFile == file)
                {
                    myOrigin = bo;
                    break;
                }
            }

            Pack p = new Pack();

            TBLogConfiguration config = file.Configurations[0];
            TBLogTarget        target = config.Target;
            TBLogAssembly      asm    = config.Assembly;

            if (!string.IsNullOrEmpty(target.KeySrc))
            {
                p.StrongNameKey = StrongNameKey.LoadFrom(QQnPath.Combine(file.ProjectPath, target.KeySrc));
            }
            else if (!string.IsNullOrEmpty(target.KeyContainer))
            {
                p.StrongNameKey = StrongNameKey.LoadFromContainer(target.KeyContainer, false);
            }

            if (asm != null && !string.IsNullOrEmpty(asm.AssemblyName))
            {
                AssemblyName name = new AssemblyName(asm.AssemblyName);
                p.Version = name.Version;
            }

            PackContainer po = p.Containers.AddItem("#ProjectOutput");

            po.ContainerDir = config.OutputPath;
            po.BaseDir      = QQnPath.Combine(file.ProjectPath);
            foreach (TBLogItem item in file.AllProjectOutput)
            {
                if (item.IsShared)
                {
                    continue;
                }

                PackFile pf = po.Files.AddItem(QQnPath.EnsureRelativePath(po.BaseDir, item.FullSrc));
                pf.StreamName = item.Src;
            }

            PackContainer ct = p.Containers.AddItem("#Content");

            ct.ContainerDir = "";
            po.BaseDir      = file.ProjectPath;

            foreach (TBLogItem item in file.AllContents)
            {
                if (item.IsShared)
                {
                    continue;
                }

                PackFile pf = po.Files.AddItem(QQnPath.EnsureRelativePath(po.BaseDir, item.FullSrc));
            }

            myOrigin.Pack = p;

            return(p);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Makes a relative path from the path
 /// </summary>
 /// <param name="include">The include.</param>
 /// <returns></returns>
 public string EnsureRelativePath(string include)
 {
     return(QQnPath.EnsureRelativePath(ProjectPath, include));
 }