public ManagedWrapperReference(XmlElement xmlDefinition, ReferencesResolver referencesResolver, ProjectBase parent, GacCache gacCache, ProjectSettings projectSettings)
            : base(xmlDefinition, referencesResolver, parent, gacCache)
        {
            if (projectSettings == null) {
                throw new ArgumentNullException("projectSettings");
            }

            _projectSettings = projectSettings;

            // determine name of wrapper reference
            XmlAttribute wrapperNameAttribute = XmlDefinition.Attributes["Name"];
            if (wrapperNameAttribute != null) {
                _name = wrapperNameAttribute.Value;
            }

            // determine wrapper tool
            XmlAttribute toolAttribute = XmlDefinition.Attributes["WrapperTool"];
            if (toolAttribute == null) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    "Wrapper tool for reference \"{0}\" in project \"{1}\" could"
                    + " not be determined.", Name, Parent.Name),
                    Location.UnknownLocation);
            }
            _wrapperTool = toolAttribute.Value;

            // determine if there's a primary interop assembly for the typelib
            _primaryInteropAssembly = GetPrimaryInteropAssembly();

            // determine filename of wrapper assembly
            _wrapperAssembly = ResolveWrapperAssembly();
        }
Exemplo n.º 2
0
 private string GetSatelliteFileName(ProjectSettings projectSettings)
 {
     return string.Format(CultureInfo.InvariantCulture,
         "{0}.resources.dll", projectSettings.AssemblyName);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets a <see cref="FileInfo" /> representing the path to the 
 /// intermediate file location of the satellite assembly.
 /// </summary>
 /// <param name="projectConfig">The project build configuration.</param>
 /// <param name="projectSettings">The project settings.</param>
 /// <returns>
 /// A <see cref="FileInfo" /> representing the path to the 
 /// intermediate file location of the satellite assembly.
 /// </returns>
 public FileInfo GetSatelliteAssemblyPath(ConfigurationSettings projectConfig, ProjectSettings projectSettings)
 {
     DirectoryInfo buildDir = GetBuildDirectory(projectConfig);
     return new FileInfo(FileUtils.CombinePaths(buildDir.FullName,
         GetSatelliteFileName(projectSettings)));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets path of the satellite assembly, relative to the output
 /// directory.
 /// </summary>
 /// <param name="projectSettings">The project settings.</param>
 /// <returns>
 /// The path of the satellite assembly, relative to the output
 /// directory.
 /// </returns>
 public string GetRelativePath(ProjectSettings projectSettings)
 {
     return FileUtils.CombinePaths(Culture.Name, GetSatelliteFileName(
         projectSettings));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManagedProjectBase"/> class.
        /// </summary>
        /// <param name="solution">The solution.</param>
        /// <param name="projectPath">The project path.</param>
        /// <param name="xmlDefinition">The XML definition.</param>
        /// <param name="solutionTask">The solution task.</param>
        /// <param name="tfc">The TFC.</param>
        /// <param name="gacCache">The gac cache.</param>
        /// <param name="refResolver">The reference resolver.</param>
        /// <param name="outputDir">The output dir.</param>
        /// <exception cref="System.ArgumentNullException">
        /// projectPath
        /// or
        /// xmlDefinition
        /// </exception>
        protected ManagedProjectBase(SolutionBase solution, string projectPath, XmlElement xmlDefinition, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver, DirectoryInfo outputDir)
            : base(xmlDefinition, solutionTask, tfc, gacCache, refResolver, outputDir)
        {
            if (projectPath == null) {
                throw new ArgumentNullException("projectPath");
            }

            if (xmlDefinition == null) {
                throw new ArgumentNullException("xmlDefinition");
            }

            _references = new ArrayList();
            _neutralResources = new ArrayList();
            _localizedResources = new ArrayList();
            _sourceFiles = CollectionsUtil.CreateCaseInsensitiveHashtable();
            _projectPath = projectPath;
            _projectLocation = DetermineProjectLocation(xmlDefinition);

            if (!IsWebProject) {
                _projectDirectory = new FileInfo(projectPath).Directory;
            } else {
                string projectDirectory = projectPath.Replace(":", "_");
                projectDirectory = projectDirectory.Replace("/", "_");
                projectDirectory = projectDirectory.Replace("\\", "_");
                _projectDirectory = new DirectoryInfo(FileUtils.CombinePaths(
                    TemporaryFiles.BasePath, projectDirectory));

                // ensure project directory exists
                if (!_projectDirectory.Exists) {
                    _projectDirectory.Create();
                    _projectDirectory.Refresh();
                }

                _webProjectBaseUrl = projectPath.Substring(0, projectPath.LastIndexOf("/"));
            }

            _projectSettings = new ProjectSettings(xmlDefinition, (XmlElement)
                xmlDefinition.SelectSingleNode("//Build/Settings"), this);

            XmlNodeList nlConfigurations = xmlDefinition.SelectNodes("//Config");
            foreach (XmlElement elemConfig in nlConfigurations) {
                ConfigurationSettings cs = new ConfigurationSettings(this, elemConfig, OutputDir);
                ProjectConfigurations[Configuration.Parse(cs.Name)] = cs;
            }

            XmlNodeList nlReferences = xmlDefinition.SelectNodes("//References/Reference");
            foreach (XmlElement elemReference in nlReferences) {
                ReferenceBase reference = CreateReference(solution, elemReference);
                _references.Add(reference);
            }

            XmlNodeList nlFiles = xmlDefinition.SelectNodes("//Files/Include/File");
            foreach (XmlElement elemFile in nlFiles) {
                string buildAction = StringUtils.ConvertEmptyToNull(elemFile.GetAttribute("BuildAction"));
                string sourceFile;

                if (!String.IsNullOrEmpty(elemFile.GetAttribute("Link"))) {
                    sourceFile = FileUtils.GetFullPath(FileUtils.CombinePaths(
                        ProjectDirectory.FullName, elemFile.GetAttribute("Link")));
                } else {
                    sourceFile = FileUtils.GetFullPath(FileUtils.CombinePaths(
                        ProjectDirectory.FullName, elemFile.GetAttribute("RelPath")));
                }

                if (IsWebProject) {
                    WebDavClient wdc = new WebDavClient(new Uri(_webProjectBaseUrl));
                    wdc.DownloadFile(sourceFile, elemFile.Attributes["RelPath"].Value);

                    switch (buildAction) {
                        case "Compile":
                            _sourceFiles[sourceFile] = null;
                            break;
                        case "EmbeddedResource":
                            RegisterEmbeddedResource(sourceFile, elemFile);
                            break;
                        case null:
                            if (string.Compare(Path.GetExtension(sourceFile), FileExtension, true, CultureInfo.InvariantCulture) == 0) {
                                _sourceFiles[sourceFile] = null;
                            }
                            break;
                    }
                } else {
                    switch (buildAction) {
                        case "Compile":
                            _sourceFiles[sourceFile] = null;
                            break;
                        case "EmbeddedResource":
                            RegisterEmbeddedResource(sourceFile, elemFile);
                            break;
                        case null:
                            if (string.Compare(Path.GetExtension(sourceFile), FileExtension, true, CultureInfo.InvariantCulture) == 0) {
                                _sourceFiles[sourceFile] = null;
                            }
                            break;
                    }

                    // check if file is "App.config" (using case-insensitive comparison)
                    if (string.Compare("App.config", elemFile.GetAttribute("RelPath"), true, CultureInfo.InvariantCulture) == 0) {
                        // App.config is only an output file for executable projects
                        if (ProjectSettings.OutputType == ManagedOutputType.Executable || ProjectSettings.OutputType == ManagedOutputType.WindowsExecutable) {
                            ExtraOutputFiles[sourceFile] = ProjectSettings.OutputFileName
                                + ".config";
                        }
                    }
                }
            }
        }
        public ManagedWrapperReference(XmlElement xmlDefinition, ReferencesResolver referencesResolver, ProjectBase parent, GacCache gacCache, ProjectSettings projectSettings) : base(xmlDefinition, referencesResolver, parent, gacCache)
        {
            if (projectSettings == null)
            {
                throw new ArgumentNullException("projectSettings");
            }

            _projectSettings = projectSettings;

            // determine name of wrapper reference
            XmlAttribute wrapperNameAttribute = XmlDefinition.Attributes["Name"];

            if (wrapperNameAttribute != null)
            {
                _name = wrapperNameAttribute.Value;
            }

            // determine wrapper tool
            XmlAttribute toolAttribute = XmlDefinition.Attributes["WrapperTool"];

            if (toolAttribute == null)
            {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                       "Wrapper tool for reference \"{0}\" in project \"{1}\" could"
                                                       + " not be determined.", Name, Parent.Name),
                                         Location.UnknownLocation);
            }
            _wrapperTool = toolAttribute.Value;

            // determine if there's a primary interop assembly for the typelib
            _primaryInteropAssembly = GetPrimaryInteropAssembly();

            // determine filename of wrapper assembly
            _wrapperAssembly = ResolveWrapperAssembly();
        }
Exemplo n.º 7
0
        public ProjectSettings(XmlElement elemRoot, XmlElement elemSettings, ManagedProjectBase project)
        {
            _project  = project;
            _settings = new ArrayList();

            // check whether build file is valid
            if (elemRoot.FirstChild == null)
            {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                       "Project file '{0}' is not valid.", Project.ProjectPath),
                                         Location.UnknownLocation);
            }

            _guid = ProjectSettings.GetProjectGuid(project.ProjectPath,
                                                   elemRoot);

            // determine output type of this project
            _outputType = GetOutputType(elemSettings);

            // initialize hashtable for holding string settings
            Hashtable htStringSettings = new Hashtable();

            switch (_outputType)
            {
            case ManagedOutputType.Library:
                _settings.Add("/target:library");
                break;

            case ManagedOutputType.Executable:
                _settings.Add("/target:exe");
                // startup object only makes sense for executable assemblies
                htStringSettings["StartupObject"] = @"/main:""{0}""";
                break;

            case ManagedOutputType.WindowsExecutable:
                _settings.Add("/target:winexe");
                // startup object only makes sense for executable assemblies
                htStringSettings["StartupObject"] = @"/main:""{0}""";
                break;
            }

            // suppresses display of Microsoft startup banner
            _settings.Add("/nologo");

            _assemblyName = elemSettings.Attributes["AssemblyName"].Value;

            // the key file to use to sign ActiveX/COM wrappers
            _assemblyOriginatorKeyFile = StringUtils.ConvertEmptyToNull(
                elemSettings.Attributes["AssemblyOriginatorKeyFile"].Value);

            // the key container to use to sign ActiveX/COM wrappers
            _assemblyKeyContainerName = StringUtils.ConvertEmptyToNull(
                elemSettings.Attributes["AssemblyKeyContainerName"].Value);

            // pre and post build events are VS .NET 2003 specific, so do not
            // assume they are there
            if (elemSettings.Attributes["RunPostBuildEvent"] != null)
            {
                _runPostBuildEvent = StringUtils.ConvertEmptyToNull(
                    elemSettings.Attributes["RunPostBuildEvent"].Value);
            }

            if (elemSettings.Attributes["PreBuildEvent"] != null)
            {
                _preBuildEvent = StringUtils.ConvertEmptyToNull(
                    elemSettings.Attributes["PreBuildEvent"].Value);
            }

            if (elemSettings.Attributes["PostBuildEvent"] != null)
            {
                _postBuildEvent = StringUtils.ConvertEmptyToNull(
                    elemSettings.Attributes["PostBuildEvent"].Value);
            }

            if (elemSettings.Attributes["RootNamespace"] != null)
            {
                _rootNamespace = StringUtils.ConvertEmptyToNull(
                    elemSettings.Attributes["RootNamespace"].Value);
                if (RootNamespace != null && Project.Type == ProjectType.VB)
                {
                    _settings.Add("/rootnamespace:" + _rootNamespace);
                }
            }

            if (elemSettings.Attributes["ApplicationIcon"] != null)
            {
                string value = StringUtils.ConvertEmptyToNull(
                    elemSettings.Attributes["ApplicationIcon"].Value);
                if (value != null)
                {
                    _applicationIcon = new FileInfo(FileUtils.CombinePaths(
                                                        Project.ProjectDirectory.FullName, value));
                }
            }

            // process VB.NET specific project settings
            if (Project.Type == ProjectType.VB)
            {
                if (elemSettings.Attributes["OptionExplicit"] != null)
                {
                    if (elemSettings.Attributes ["OptionExplicit"].Value == "Off")
                    {
                        _settings.Add("/optionexplicit-");
                    }
                    else
                    {
                        _settings.Add("/optionexplicit+");
                    }
                }

                if (elemSettings.Attributes["OptionStrict"] != null)
                {
                    if (elemSettings.Attributes ["OptionStrict"].Value == "Off")
                    {
                        _settings.Add("/optionstrict-");
                    }
                    else
                    {
                        _settings.Add("/optionstrict+");
                    }
                }

                if (elemSettings.Attributes["OptionCompare"] != null)
                {
                    if (elemSettings.Attributes ["OptionCompare"].Value == "Text")
                    {
                        _settings.Add("/optioncompare:text");
                    }
                    else
                    {
                        _settings.Add("/optioncompare:binary");
                    }
                }
            }

            foreach (DictionaryEntry de in htStringSettings)
            {
                string value = elemSettings.GetAttribute(de.Key.ToString());
                if (String.IsNullOrEmpty(value))
                {
                    // skip empty values
                    continue;
                }
                _settings.Add(string.Format(de.Value.ToString(), value));
            }
        }