Beispiel #1
0
 private Shortcut(Component component, WiXElement target, string name, DirectoryRef directory)
     : this(component, name, directory)
 {
     Target = string.Format("[{0}]", target.Id);
 }
Beispiel #2
0
 public Shortcut(CreateFolder createFolder, string name, DirectoryRef directory)
     : this((WiXElement)createFolder, name, directory)
 {
 }
 public Directory(DirectoryRef parent, string name, string Id)
     : this(parent.Element, name, Id)
 {
 }
Beispiel #4
0
 public Shortcut(Component component, File target, string name, DirectoryRef directory)
     : this(component, (WiXElement)target, name, directory)
 {
 }
Beispiel #5
0
 public Shortcut(File file, string name, DirectoryRef directory)
     : this((WiXElement)file, name, directory)
 {
 }
Beispiel #6
0
 private Shortcut(WiXElement parent, string name, DirectoryRef directory)
     : base(parent.Element, "Shortcut", "shortcut" + shortcutCount++)
 {
     Directory = directory.Id;
     Name      = name;
 }
Beispiel #7
0
 private Shortcut(Component component, WiXElement target, string name, DirectoryRef directory)
     : this(component, name, directory)
 {
     Target = string.Format("[{0}]", target.Id);
 }
 public Component(DirectoryRef parent)
     : this(parent, "component" + componentCount++, Guid.NewGuid())
 {
 }
Beispiel #9
0
 public Component(DirectoryRef parent, string Id, Guid guid)
     :
     this(parent.Element, Id, guid)
 {
 }
Beispiel #10
0
 public Shortcut(Component component, File target, string name, DirectoryRef directory)
     : this(component, (WiXElement)target, name, directory)
 {
 }
Beispiel #11
0
 public Component(DirectoryRef parent)
     : this(parent, "component" + componentCount++, Guid.NewGuid())
 {
 }
Beispiel #12
0
 public Directory(DirectoryRef parent, string name, string Id)
     : this(parent.Element, name, Id)
 {
 }
Beispiel #13
0
 public Component(DirectoryRef parent, string Id, Guid guid)
     :
     this(parent.Element, Id, guid)
 {
 }
Beispiel #14
0
 public Shortcut(File file, string name, DirectoryRef directory)
     : this((WiXElement)file, name, directory)
 {     
 }
Beispiel #15
0
 public Shortcut(CreateFolder createFolder, string name, DirectoryRef directory)
     : this((WiXElement)createFolder, name, directory)
 {
 }
Beispiel #16
0
 private Shortcut(WiXElement parent, string name, DirectoryRef directory)
     : base(parent.Element, "Shortcut", "shortcut" + shortcutCount++)
 {
     Directory = directory.Id;
     Name = name;
 }
        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;
            }
        }