示例#1
0
        public WixFileNode AddFileNode([NotNull] FileMapping fileMapping)
        {
            Contract.Requires(fileMapping != null);

            var targetName = fileMapping.TargetName;

            var name          = Path.GetFileName(targetName);
            var id            = GetFileId(targetName);
            var directoryName = Path.GetDirectoryName(targetName);
            var directoryId   = GetDirectoryId(directoryName);
            var directory     = DirectoryNodes.FirstOrDefault(node => node.Id.Equals(directoryId, StringComparison.OrdinalIgnoreCase));

            directoryId = directory != null ? directory.Id : "TODO: unknown directory " + directoryName;

            var componentGroup = ForceComponentGroup(directoryId);

            if (componentGroup == null)
            {
                return(null);
            }

            ForceFeatureRef(componentGroup.Id);

            return(componentGroup.AddFileComponent(id, name, fileMapping));
        }
示例#2
0
        public WixDirectoryNode AddDirectoryNode([NotNull] string directory)
        {
            Contract.Requires(directory != null);
            Contract.Ensures(Contract.Result <WixDirectoryNode>() != null);

            var name = Path.GetFileName(directory);
            var id   = GetDirectoryId(directory);
            var parentDirectoryName = Path.GetDirectoryName(directory);
            var parentId            = string.IsNullOrEmpty(directory) ? string.Empty : GetDirectoryId(parentDirectoryName);

            var parent = DirectoryNodes.FirstOrDefault(node => node.Id.Equals(parentId));

            if (parent == null)
            {
                if (!string.IsNullOrEmpty(parentId))
                {
                    parent = AddDirectoryNode(parentDirectoryName);
                }
                else
                {
                    parentId = "TODO:" + Guid.NewGuid();
                    var sourceFile = _sourceFiles.FirstOrDefault();
                    Contract.Assume(sourceFile != null);
                    return(sourceFile.AddDirectory(id, name, parentId));
                }
            }

            return(parent.AddSubdirectory(id, name));
        }