コード例 #1
0
 private Shortcut(Component component, WiXElement target, string name, DirectoryRef directory)
     : this(component, name, directory)
 {
     Target = string.Format("[{0}]", target.Id);
 }
コード例 #2
0
 public Shortcut(CreateFolder createFolder, string name, DirectoryRef directory)
     : this((WiXElement)createFolder, name, directory)
 {
 }
コード例 #3
0
 public Directory(DirectoryRef parent, string name, string Id)
     : this(parent.Element, name, Id)
 {
 }
コード例 #4
0
 public Shortcut(Component component, File target, string name, DirectoryRef directory)
     : this(component, (WiXElement)target, name, directory)
 {
 }
コード例 #5
0
 public Shortcut(File file, string name, DirectoryRef directory)
     : this((WiXElement)file, name, directory)
 {
 }
コード例 #6
0
 private Shortcut(WiXElement parent, string name, DirectoryRef directory)
     : base(parent.Element, "Shortcut", "shortcut" + shortcutCount++)
 {
     Directory = directory.Id;
     Name      = name;
 }
コード例 #7
0
 private Shortcut(Component component, WiXElement target, string name, DirectoryRef directory)
     : this(component, name, directory)
 {
     Target = string.Format("[{0}]", target.Id);
 }
コード例 #8
0
 public Component(DirectoryRef parent)
     : this(parent, "component" + componentCount++, Guid.NewGuid())
 {
 }
コード例 #9
0
 public Component(DirectoryRef parent, string Id, Guid guid)
     :
     this(parent.Element, Id, guid)
 {
 }
コード例 #10
0
 public Shortcut(Component component, File target, string name, DirectoryRef directory)
     : this(component, (WiXElement)target, name, directory)
 {
 }
コード例 #11
0
 public Component(DirectoryRef parent)
     : this(parent, "component" + componentCount++, Guid.NewGuid())
 {
 }
コード例 #12
0
 public Directory(DirectoryRef parent, string name, string Id)
     : this(parent.Element, name, Id)
 {
 }
コード例 #13
0
 public Component(DirectoryRef parent, string Id, Guid guid)
     :
     this(parent.Element, Id, guid)
 {
 }
コード例 #14
0
 public Shortcut(File file, string name, DirectoryRef directory)
     : this((WiXElement)file, name, directory)
 {     
 }
コード例 #15
0
 public Shortcut(CreateFolder createFolder, string name, DirectoryRef directory)
     : this((WiXElement)createFolder, name, directory)
 {
 }
コード例 #16
0
 private Shortcut(WiXElement parent, string name, DirectoryRef directory)
     : base(parent.Element, "Shortcut", "shortcut" + shortcutCount++)
 {
     Directory = directory.Id;
     Name = name;
 }
コード例 #17
0
        public override bool Execute()
        {
            try
            {
                //
                // Do some setup
                //
                this.Log.LogMessage("Create Assembly Fragment Task");

                string assemblyRoot = Path.GetFileNameWithoutExtension(assemblyName);

                if (fragmentId == null)
                {
                    fragmentId = "Fragment" + assemblyEndian + assemblyName;
                }

                componentId = "Component" + assemblyEndian + assemblyName;

                //
                // Build WiX file
                //
                Fragment fragment = new Fragment(fragmentId);

                if (includeFiles != null)
                {
                    foreach (ITaskItem item in includeFiles)
                    {
                        if (item == null) continue;
                        fragment.PrependInclude(item.ItemSpec);
                    }
                }

                DirectoryRef dirref = new DirectoryRef(
                    fragment,
                    directoryRef);


                Component fileComponent = null;

                // Create Component and add files
                if (componentGuid != Guid.Empty)
                {
                    // Generate new GUID for BE files, else BE files will be stranded upon uninstall
                    if ( assemblyEndian == "_be_" )
                    {
                        componentGuid = Guid.NewGuid();
                    }
 
                    fileComponent = new Component(
                        dirref,
                        componentId,
                        componentGuid);

                    fragment.PrependDefine(
                        string.Format("COMPONENTID=\"{0}\"", fileComponent.Id));

                    foreach (ITaskItem item in componentFiles)
                    {
                        if (item == null) continue;
                        string fileName = item.ItemSpec;

                        string assemblyType = item.GetMetadata("AssemblyType");
                        assemblyType = String.IsNullOrEmpty(assemblyType) ? "" : assemblyType.ToLower();

                        if ( assemblyType != "" )
                        {
                            if ( assemblyType != ".net" && assemblyType != "win32" && assemblyType != "no" )
                            {
                                throw new ApplicationException("Invalid assemblyType \"" + assemblyType + "\" in file metadata ");
                            }
                        }

                        Microsoft.SPOT.WiX.File file = new Microsoft.SPOT.WiX.File(
                            fileComponent,
                            item.GetMetadata("Name"),
                            fileName,
                            false);

                        file.Id = file.Id + assemblyEndian;

                        fragment.PrependDefine(
                                string.Format("ID{0}=\"{1}\"", file.Name.Replace('.', '_'), file.Id));

                        if(!string.IsNullOrEmpty(assemblyShortcut) && fileName.ToLower().EndsWith(".exe"))
                        {
                            Shortcut sc = new Shortcut(file, assemblyShortcut, new DirectoryRef(fragment,"ProgramMenuDir"));
                        }
                    }

                    if (componentIncludeFiles != null)
                    {
                        foreach (ITaskItem item in componentIncludeFiles)
                        {
                            if (item == null) continue;
                            fileComponent.AppendInclude(item.ItemSpec);
                        }
                    }
                }

                if (postIncludeFiles != null)
                {
                    foreach (ITaskItem item in postIncludeFiles)
                    {
                        if (item == null) continue;
                        fragment.AppendInclude(item.ItemSpec);
                    }
                }

                // Save Fragment File
                string fragmentFileDirectory = Path.GetDirectoryName(fragmentFileName);

                if (!System.IO.Directory.Exists(fragmentFileDirectory))
                {
                    System.IO.Directory.CreateDirectory(fragmentFileDirectory);
                }

                fragment.Element.OwnerDocument.Save(fragmentFileName);

                return true;
            }
            catch (Exception e)
            {
                this.Log.LogErrorFromException(e);
                return false;
            }
        }