public MSBuildConfiguration(MSBuildProject project, NAnt.MSBuild.BuildEngine.Project msproj, Configuration projectConfig) : base(project) { _name = projectConfig.Name; _platform = projectConfig.Platform; //explicit set. EvaluatedProperties will use those. //Its caller responsibility to set it back to original values, if needed msproj.GlobalProperties.SetProperty("Configuration", _name); if (!String.IsNullOrEmpty(_platform)) { msproj.GlobalProperties.SetProperty("Platform", _platform.Replace(" ", string.Empty)); } _relativeOutputDir = msproj.GetEvaluatedProperty("OutputPath"); if (!_relativeOutputDir.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))) { _relativeOutputDir = _relativeOutputDir + Path.DirectorySeparatorChar; } _outputDir = new DirectoryInfo(FileUtils.CombinePaths( project.ProjectDirectory.FullName, _relativeOutputDir)); _objdir = new DirectoryInfo(msproj.GetEvaluatedProperty("IntermediateOutputPath")); _outputType = GetType(msproj.GetEvaluatedProperty("OutputType")); _asmname = msproj.GetEvaluatedProperty("AssemblyName"); }
public MSBuildConfiguration(MSBuildProject project, Microsoft.Build.BuildEngine.Project msproj, Configuration projectConfig) : base(project) { _name = projectConfig.Name; msproj.GlobalProperties.SetProperty("Configuration", _name); project.SetPlatform (projectConfig.Platform); _platform = msproj.GetEvaluatedProperty("Platform"); _relativeOutputDir = msproj.GetEvaluatedProperty("OutputPath"); if (!_relativeOutputDir.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))) { _relativeOutputDir = _relativeOutputDir + Path.DirectorySeparatorChar; } _outputDir = new DirectoryInfo(FileUtils.CombinePaths( project.ProjectDirectory.FullName, _relativeOutputDir)); _objdir = new DirectoryInfo(msproj.GetEvaluatedProperty("IntermediateOutputPath")); _outputType = GetType(msproj.GetEvaluatedProperty("OutputType")); _asmname = msproj.GetEvaluatedProperty("AssemblyName"); }
public MSBuildConfiguration(MSBuildProject project, Microsoft.Build.BuildEngine.Project msproj, Configuration projectConfig) : base(project) { _name = projectConfig.Name; msproj.GlobalProperties.SetProperty("Configuration", _name); project.SetPlatform(projectConfig.Platform); _platform = msproj.GetEvaluatedProperty("Platform"); _relativeOutputDir = msproj.GetEvaluatedProperty("OutputPath"); if (!_relativeOutputDir.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))) { _relativeOutputDir = _relativeOutputDir + Path.DirectorySeparatorChar; } _outputDir = new DirectoryInfo(FileUtils.CombinePaths( project.ProjectDirectory.FullName, _relativeOutputDir)); _objdir = new DirectoryInfo(msproj.GetEvaluatedProperty("IntermediateOutputPath")); _outputType = GetType(msproj.GetEvaluatedProperty("OutputType")); _asmname = msproj.GetEvaluatedProperty("AssemblyName"); }
/// <summary> /// Initializes a new instance of the <see cref="ProjectSettings"/> class. /// </summary> /// <param name="elemRoot">The elem root.</param> /// <param name="elemSettings">The elem settings.</param> /// <param name="project">The project.</param> /// <exception cref="BuildException"></exception> 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)); } }