public static (bool includesSaved, bool macrosSaved) CheckSavedIncludesAndMacros(VCProject p) { bool includesSaved = true; bool macrosSaved = true; foreach (VCConfiguration2 config in p.Configurations) { IVCRulePropertyStorage plcnextCommonPropertiesRule = config.Rules.Item(Constants.PLCnextRuleName); if (plcnextCommonPropertiesRule == null) { MessageBox.Show($"{Constants.PLCnextRuleName} rule was not found in configuration rules collection."); } if (string.IsNullOrEmpty(plcnextCommonPropertiesRule.GetUnevaluatedPropertyValue(Constants.PLCnextIncludesKey))) { includesSaved = false; } if (string.IsNullOrEmpty(plcnextCommonPropertiesRule.GetUnevaluatedPropertyValue(Constants.PLCnextMacrosKey))) { macrosSaved = false; } if (!includesSaved && !macrosSaved) { break; } } return(includesSaved, macrosSaved); }
public static void SetIncludesForNewProject(VCProject vcProject, CompilerSpecificationCommandResult compilerSpecsCommandResult, ProjectInformationCommandResult projectInformation) { (IEnumerable <CompilerMacroResult> macros, IEnumerable <string> includes) = ProjectIncludesManager.FindMacrosAndIncludesForMinTarget(compilerSpecsCommandResult, projectInformation); if (macros == null) { macros = Enumerable.Empty <CompilerMacroResult>(); } if (includes == null) { includes = Enumerable.Empty <string>(); } foreach (VCConfiguration2 config in vcProject.Configurations) { IVCRulePropertyStorage plcnextCommonPropertiesRule = config.Rules.Item(Constants.PLCnextRuleName); if (plcnextCommonPropertiesRule == null) { MessageBox.Show("PLCnextCommonProperties rule was not found in configuration rules collection."); } string joinedMacros = macros.Any() ? string.Join(";", macros.Select(m => m.Name + (string.IsNullOrEmpty(m.Value.Trim()) ? null : "=" + m.Value))) : string.Empty; string joinedIncludes = includes.Any() ? string.Join(";", includes) : string.Empty; plcnextCommonPropertiesRule.SetPropertyValue(Constants.PLCnextMacrosKey, joinedMacros); plcnextCommonPropertiesRule.SetPropertyValue(Constants.PLCnextIncludesKey, joinedIncludes); } }
private ProjectProperties.StandardVersion GetStandardVersion(VCConfiguration config) { IVCRulePropertyStorage generalRule = config.Rules.Item("ConfigurationGeneral"); string value = null; try { value = generalRule == null ? null : generalRule.GetEvaluatedPropertyValue("LanguageStandard"); } catch (Exception) { } if (value == "Default") { return(ProjectProperties.StandardVersion.Default); } else if (value == "stdcpp14") { return(ProjectProperties.StandardVersion.Cpp14); } else if (value == "stdcpp17") { return(ProjectProperties.StandardVersion.Cpp17); } else if (value == "stdcpplatest") { return(ProjectProperties.StandardVersion.Latest); } return(ProjectProperties.StandardVersion.Latest); }
VCNMakeToolWrapperVs2017 #endif (object wrapped) { _wrapped = wrapped as VCNMakeTool; _wrappedRules = wrapped as IVCRulePropertyStorage; }
public void OverrideSDKRootPepper() { string slnName = TestUtilities.CreateBlankValidNaClSolution( dte_, "OverrideSDKRootPepper", Strings.PepperPlatformName, Strings.PepperPlatformName, TestContext); OpenSolutionAndGetProperties(slnName, Strings.PepperPlatformName); // VC++ Directories string page = "ConfigurationGeneral"; IVCRulePropertyStorage pageStorage = debug_.Rules.Item(page); pageStorage.SetPropertyValue("VSNaClSDKRoot", @"foo\"); page = "ConfigurationDirectories"; TestUtilities.AssertPropertyContains(debug_, page, "IncludePath", @"foo\include;", true, true); TestUtilities.AssertPropertyContains(debug_, page, "IncludePath", @"foo\include\win;", true, true); TestUtilities.AssertPropertyContains(debug_, page, "IncludePath", @"foo\include", true, true); TestUtilities.AssertPropertyContains(debug_, page, "LibraryPath", @"foo\lib\win_x86_32_host", true, true); TestUtilities.AssertPropertyContains(debug_, page, "LibraryPath", @"foo\lib", true, true); dte_.Solution.Close(); }
/// <summary> /// Tests that a given property contains a specific string in a certain VCConfiguration /// </summary> /// <param name="configuration">Gives the platform and configuration type</param> /// <param name="pageName">Property page name where property resides.</param> /// <param name="propertyName">Name of the property to check.</param> /// <param name="expectedValue">Expected string to contain.</param> /// <param name="ignoreCase">Ignore case when comparing the expected and actual values.</param> public static void AssertPropertyContains( VCConfiguration configuration, string pageName, string propertyName, string expectedValue, bool ignoreCase, bool expand = false) { StringComparison caseSensitive = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; IVCRulePropertyStorage rule = configuration.Rules.Item(pageName); string propertyValue; if (expand) { propertyValue = rule.GetEvaluatedPropertyValue(propertyName); } else { propertyValue = rule.GetUnevaluatedPropertyValue(propertyName); } string message = string.Format( "{0} should be contained in {1}. Page: {2}, Property: {3}, Configuration: {4}", expectedValue, propertyValue, pageName, propertyName, configuration.ConfigurationName); Assert.IsTrue(propertyValue.Contains(expectedValue, caseSensitive), message); }
public static void AddToProperty(Solution2 solution, string projectName, string buildConfig, string ruleName, string property, string additionalData) { IVCRulePropertyStorage rule = GetPropertyStorage(solution, projectName, buildConfig, ruleName, property); string previousDependencies = rule.GetUnevaluatedPropertyValue(property); rule.SetPropertyValue(property, additionalData + ';' + previousDependencies); }
protected void QueryStatus(object sender, EventArgs e) { if (sender is OleMenuCommand cmd) { try { Project project = GetProject(); if (project != null) { if (project.Object is VCProject p) { VCConfiguration configuration = p.ActiveConfiguration; IVCRulePropertyStorage plcnextRule = configuration.Rules.Item("PLCnextCommonProperties"); string projectType = plcnextRule.GetUnevaluatedPropertyValue("ProjectType_"); if (!string.IsNullOrEmpty(projectType)) { cmd.Visible = true; return; } } } } catch (Exception) { //cmd visibility will be set to false } cmd.Visible = false; } }
VCCLCompilerToolWrapperVs2019 #endif (object wrapped) { _wrapped = wrapped as VCCLCompilerTool; _wrappedRules = wrapped as IVCRulePropertyStorage; }
/// <summary> /// Goes through all projects in the solution and updates their properties with necessary /// modifications if they are NaCl or Pepper configurations. We add the version information /// here so that the version is stored directly in the project file. The call to /// PerformPropertyFixes() performs a work around on the property pages to force Visual Studio /// to save some specific properties into the project file to get around issue 140162. /// </summary> private void PerformPropertyModifications() { string naclAddInVersion = GetAddInMajorVersion().ToString(); var configs = Utility.GetPlatformVCConfigurations(dte_, Strings.PepperPlatformName); configs.AddRange(Utility.GetPlatformVCConfigurations(dte_, Strings.NaCl64PlatformName)); configs.AddRange(Utility.GetPlatformVCConfigurations(dte_, Strings.NaCl32PlatformName)); configs.AddRange(Utility.GetPlatformVCConfigurations(dte_, Strings.PNaClPlatformName)); var properties = new PropertyManager(); foreach (VCConfiguration config in configs) { properties.SetTarget(config); IVCRulePropertyStorage debugger = config.Rules.Item("WindowsLocalDebugger"); string executable = debugger.GetUnevaluatedPropertyValue("LocalDebuggerCommand"); // Perform project modifications of the NaClAddInVersion in the project file // is out of date, or if the WindowsLocalDebugger contains CHROME_PATH. The // later can happen if the developer deletes the .user file. if (executable.Contains("$(CHROME_PATH)") || properties.NaClAddInVersion != naclAddInVersion) { Debug.WriteLine("Modifying Config: " + config.Name); // Set the NaCl add-in version so that it is stored in the project file. properties.SetProperty("ConfigurationGeneral", "NaClAddInVersion", naclAddInVersion); // Expand the CHROME_PATH variable to its full path. string expandedChrome = properties.GetProperty( "WindowsLocalDebugger", "LocalDebuggerCommand"); properties.SetProperty("WindowsLocalDebugger", "LocalDebuggerCommand", expandedChrome); // Change the library includes to have the appropriate extension. string libs = properties.GetProperty("Link", "AdditionalDependencies"); if (properties.PlatformType == PropertyManager.ProjectPlatformType.NaCl) { libs = libs.Replace(".lib", string.Empty); } else if (properties.PlatformType == PropertyManager.ProjectPlatformType.Pepper) { string[] libsList = libs.Split(';'); libs = string.Empty; foreach (string lib in libsList) { string baseLibName = lib.Replace(".lib", string.Empty); if (!string.IsNullOrWhiteSpace(lib)) { libs = string.Concat(libs, baseLibName, ".lib;"); } } } properties.SetProperty("Link", "AdditionalDependencies", libs); } } }
public static IVCRulePropertyStorage GetPropertyStorage(Solution2 solution, string projectName, string buildConfig, string ruleName, string property) { VCProject fsgdGameProject = solution.Projects.Item(projectName).Object as VCProject; VCConfiguration config = fsgdGameProject.Configurations.Item(buildConfig) as VCConfiguration; IVCRulePropertyStorage propertyStorage = config.Rules.Item(ruleName); return(propertyStorage); }
VcProjectAdapter(VCProject vcProject) { vcProject.LoadUserFile(); this.vcProject = vcProject; var vcConfiguration = vcProject.ActiveConfiguration; generalRule = vcConfiguration.Rules.Item("ConfigurationGeneral") as IVCRulePropertyStorage; nmakeRule = vcConfiguration.Rules.Item( "ConfigurationNMake") as IVCRulePropertyStorage; }
private static string GetInstallationDirectoryImpl(ISettingsService settingsService, VCConfiguration configuration) { string installPath = ".conan"; if (settingsService != null && settingsService.GetConanGenerator() == ConanGeneratorType.visual_studio) { IVCRulePropertyStorage generalSettings = configuration.Rules.Item("ConfigurationGeneral"); string outputDirectory = generalSettings.GetEvaluatedPropertyValue("OutDir"); return(Path.Combine(outputDirectory, installPath)); } return(Path.Combine(configuration.project.ProjectDirectory, installPath)); }
public int OnBeforeSave(uint docCookie) { ThreadHelper.ThrowIfNotOnUIThread(); try { string documentPath = GetDocumentInfos(); string GetDocumentInfos() { runningDocumentTable.GetDocumentInfo(docCookie, out uint pgfFlags, out uint pdwReadLocks, out uint pdfEditLocks, out string pbstrMkDocument, out IVsHierarchy ppHier, out uint pitemid, out IntPtr ppunkDocData); return(pbstrMkDocument); } DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE; ProjectItem projectItem = dte.Solution.FindProjectItem(documentPath); Project project = projectItem.ContainingProject; VCProject p = project.Object as VCProject; VCConfiguration configuration = p.ActiveConfiguration; IVCRulePropertyStorage plcnextRule = configuration.Rules.Item("PLCnextCommonProperties"); string projectType = plcnextRule.GetUnevaluatedPropertyValue("ProjectType_"); if (!string.IsNullOrEmpty(projectType)) { string name = Path.GetFileName(documentPath); if (name.Equals(fileName)) { if (optionPage.AskIncludesUpdate) { UpdateIncludesViewModel viewModel = new UpdateIncludesViewModel(p.Name); UpdateIncludesDialogView view = new UpdateIncludesDialogView(viewModel); bool result = (bool)view.ShowModal(); optionPage.UpdateIncludes = result; if (viewModel.RememberDecision) { optionPage.AskIncludesUpdate = false; } } if (optionPage.UpdateIncludes) { UpdateIncludesOnBeforeSave(p, p.ProjectDirectory); } } return(VSConstants.S_OK); } } catch (NullReferenceException) { //do nothing } return(VSConstants.S_OK); }
private static ConanConfiguration ExtractConanConfiguration(VCConfiguration configuration) { var x = configuration.Platform; IVCRulePropertyStorage generalSettings = configuration.Rules.Item("ConfigurationGeneral"); var toolset = generalSettings.GetEvaluatedPropertyValue("PlatformToolset"); return(new ConanConfiguration { Architecture = GetArchitecture(configuration.Platform.Name), BuildType = GetBuildType(configuration.ConfigurationName), CompilerToolset = toolset, CompilerVersion = "15" }); }
/// <summary> /// </summary> protected string GetPropertyValue(string pageRule, string propertyName, bool evaluated = true, object configName = null) { if (configName == null) { configName = 1; } IVCCollection configs = Project.Configurations; VCConfiguration config = configs.Item(configName); IVCRulePropertyStorage storage = config.Rules.Item(pageRule); return(evaluated ? storage.GetEvaluatedPropertyValue(propertyName) : storage.GetUnevaluatedPropertyValue(propertyName)); }
public void ProjectFinishedGenerating(Project project) { // use VCProject.LatestTargetPlatformVersion property, which is what the stock wizards use. VCProject vcProject = (VCProject)project.Object; string wtpv = vcProject.LatestTargetPlatformVersion; if (wtpv != null) { // we only have to do this for a single config, as the property in question is global. IVCCollection configs = (IVCCollection)vcProject.Configurations; VCConfiguration firstConfig = (VCConfiguration)configs.Item(1); IVCRulePropertyStorage rule = (IVCRulePropertyStorage)firstConfig.Rules.Item("ConfigurationGeneral"); rule?.SetPropertyValue("WindowsTargetPlatformVersion", wtpv); } }
private static Dictionary <string, string> getParametersFromFakeProperties(IVCRulePropertyStorage vcfprop, System.Reflection.PropertyInfo[] props) { var parameters = new Dictionary <string, string>(); foreach (var p in props) { var val = vcfprop.GetEvaluatedPropertyValue(p.Name); if (!string.IsNullOrEmpty(val)) { parameters[p.Name] = val; } } return(parameters); }
/// <summary> /// Tests that a given property is not null or empty. /// </summary> /// <param name="configuration">Gives the platform and configuration type</param> /// <param name="pageName">Property page name where property resides.</param> /// <param name="propertyName">Name of the property to check.</param> public static void AssertPropertyIsNotNullOrEmpty( VCConfiguration configuration, string pageName, string propertyName) { IVCRulePropertyStorage rule = configuration.Rules.Item(pageName); string propertyValue = rule.GetUnevaluatedPropertyValue(propertyName); string message = string.Format( "{0} was null or empty. Page: {1}, Configuration: {2}", propertyName, pageName, configuration.ConfigurationName); Assert.IsFalse(string.IsNullOrEmpty(propertyValue), message); }
private static ConanConfiguration ExtractConanConfiguration(ISettingsService settingsService, VCConfiguration configuration) { IVCRulePropertyStorage generalSettings = configuration.Rules.Item("ConfigurationGeneral"); var toolset = generalSettings.GetEvaluatedPropertyValue("PlatformToolset"); string installPath = GetInstallationDirectoryImpl(settingsService, configuration); var VCCLCompilerTool = configuration.Tools.Item("VCCLCompilerTool"); return(new ConanConfiguration { Architecture = GetArchitecture(configuration.Platform.Name), BuildType = GetBuildType(configuration.ConfigurationName), CompilerToolset = toolset, CompilerVersion = "15", InstallPath = installPath, RuntimeLibrary = runtimeLibraryToString(VCCLCompilerTool.RuntimeLibrary) }); }
/// <summary> /// </summary> protected void SetPropertyValue(string pageRule, string propertyName, string propertyValue, object configName = null) { if (configName == null) { foreach (VCConfiguration config in Project.Configurations) { IVCRulePropertyStorage storage = config.Rules.Item(pageRule); storage.SetPropertyValue(propertyName, propertyValue); } } else { IVCCollection configs = Project.Configurations; VCConfiguration config = configs.Item(configName); IVCRulePropertyStorage storage = config.Rules.Item(pageRule); storage.SetPropertyValue(propertyName, propertyValue); } }
/// <summary> /// Tests that a given property has a specific value in a certain VCConfiguration /// </summary> /// <param name="configuration">Gives the platform and configuration type</param> /// <param name="pageName">Property page name where property resides.</param> /// <param name="propertyName">Name of the property to check.</param> /// <param name="expectedValue">Expected value of the property.</param> /// <param name="ignoreCase">Ignore case when comparing the expected and actual values.</param> public static void AssertPropertyEquals( VCConfiguration configuration, string pageName, string propertyName, string expectedValue, bool ignoreCase) { IVCRulePropertyStorage rule = configuration.Rules.Item(pageName); string callInfo = string.Format( "Page: {0}, Property: {1}, Configuration: {2}", pageName, propertyName, configuration.ConfigurationName); Assert.AreEqual( expectedValue, rule.GetUnevaluatedPropertyValue(propertyName), ignoreCase, callInfo); }
public void ProjectFinishedGenerating(Project project) { VCProject vcproject = null; vcproject = project.Object as VCProject; var addons = inputForm.getAddons(); itemName = vcproject.ItemName; Wizard.addAddons(vcproject, ofRoot, addons); Wizard.saveAddonsMake(vcproject, addons); string ofProject; if (Path.IsPathRooted(ofRoot)) { ofProject = Path.Combine(ofRoot, "libs\\openFrameworksCompiled\\project\\vs\\openFrameworksLib.vcxproj"); } else { string[] path = { Path.GetDirectoryName(project.FullName), ofRoot, "libs\\openFrameworksCompiled\\project\\vs\\openFrameworksLib.vcxproj" }; ofProject = Path.Combine(path); } dte.Solution.AddFromFile(ofProject); //Setting the Windows target platform version of the project //to avoid the error with Windows SDK //Same problem as described here: https://sharepointforum.org/threads/creating-a-vsix-deployable-c-project-template.142260/ // use VCProject.LatestTargetPlatformVersion property, which is what the stock wizards use. VCProject vcProject = (VCProject)project.Object; string wtpv = vcProject.LatestTargetPlatformVersion; if (wtpv != null) { // we only have to do this for a single config, as the property in question is global. IVCCollection configs = (IVCCollection)vcProject.Configurations; VCConfiguration firstConfig = (VCConfiguration)configs.Item(1); IVCRulePropertyStorage rule = (IVCRulePropertyStorage)firstConfig.Rules.Item("ConfigurationGeneral"); rule?.SetPropertyValue("WindowsTargetPlatformVersion", wtpv); } }
/// <summary> /// Sets any generic property to the current target properties. /// </summary> /// <param name="page">Page where property is located.</param> /// <param name="name">Name of the property.</param> /// <param name="value">Unevaluated string value to set.</param> public virtual void SetProperty(string page, string name, string value) { IVCRulePropertyStorage pageStorage = configuration_.Rules.Item(page); pageStorage.SetPropertyValue(name, value); }
public static string GetUnevaluatedProperty(Solution2 solution, string projectName, string buildConfig, string ruleName, string property, string additionalData) { IVCRulePropertyStorage rule = GetPropertyStorage(solution, projectName, buildConfig, ruleName, property); return(rule.GetUnevaluatedPropertyValue(property)); }
public static void SetProperty(Solution2 solution, string projectName, string buildConfig, string ruleName, string property, string additionalData) { IVCRulePropertyStorage rule = GetPropertyStorage(solution, projectName, buildConfig, ruleName, property); rule.SetPropertyValue(property, additionalData); }
protected override bool BeforeTraverseProject(Project project) { //var propertyIter = project.Properties.GetEnumerator(); //while (propertyIter.MoveNext() && false) //{ // var item = propertyIter.Current as Property; // if (item == null) // { // continue; // } // string propName = item.Name; // string propValue = ""; // try // { // propValue = item.Value.ToString(); // } // catch // { // } // Logger.WriteLine(" " + propName + ":" + propValue); //} try { // Skip unselected projects if (m_onlySelectedProjects) { var projectID = project.UniqueName; if (!m_selectedProjID.Contains(projectID)) { return(false); } } Logger.Debug("Traversing Project:" + project.Name); var codeModel = project.CodeModel; if (codeModel != null) { var projInfo = FindProjectInfo(project.UniqueName); if (codeModel.Language == CodeModelLanguageConstants.vsCMLanguageCSharp) { projInfo.m_language = "csharp"; } else if (codeModel.Language == CodeModelLanguageConstants.vsCMLanguageVC) { projInfo.m_language = "cpp"; } else { projInfo.m_language = ""; } } //var configMgr = project.ConfigurationManager; //var config = configMgr.ActiveConfiguration as Configuration; var vcProject = project.Object as VCProject; Logger.Debug("check vc project"); if (vcProject != null) { var vccon = vcProject.ActiveConfiguration as VCConfiguration; IVCRulePropertyStorage generalRule = vccon.Rules.Item("ConfigurationDirectories"); IVCRulePropertyStorage cppRule = vccon.Rules.Item("CL"); // Parsing include path string addIncPath = cppRule.GetEvaluatedPropertyValue("AdditionalIncludeDirectories"); string incPath = generalRule.GetEvaluatedPropertyValue("IncludePath"); string allIncPath = incPath + ";" + addIncPath; string[] pathList = allIncPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var projectInc = new HashSet <string>(); var projectPath = Path.GetDirectoryName(project.FileName); foreach (var item in pathList) { string path = item.Trim(); if (!path.Contains(":")) { // relative path path = Path.Combine(projectPath, path); path = Path.GetFullPath((new Uri(path)).LocalPath); } if (!Directory.Exists(path)) { continue; } path = path.Replace('\\', '/').Trim(); projectInc.Add(path); Logger.Debug("include path:" + path); } var projInfo = FindProjectInfo(project.UniqueName); projInfo.m_includePath = projectInc; // Parsing define string defines = cppRule.GetEvaluatedPropertyValue("PreprocessorDefinitions"); string[] defineList = defines.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var defineSet = new HashSet <string>(); foreach (var item in defineList) { defineSet.Add(item); } projInfo.m_defines = defineSet; } //foreach (VCConfiguration vccon in vcProject.Configurations) //{ // string ruleStr = "ConfigurationDirectories"; // IVCRulePropertyStorage generalRule = vccon.Rules.Item(ruleStr); // IVCRulePropertyStorage cppRule = vccon.Rules.Item("CL"); // string addIncPath = cppRule.GetEvaluatedPropertyValue("AdditionalIncludeDirectories"); // string incPath = generalRule.GetEvaluatedPropertyValue("IncludePath"); // string outputPath = vccon.OutputDirectory; // //vccon.OutputDirectory = "$(test)"; // //string test1 = generalRule.GetEvaluatedPropertyValue(2); // //string incPath = generalRule.GetEvaluatedPropertyValue("IncludePath"); // //string name = generalRule.GetEvaluatedPropertyValue("TargetName"); // Logger.WriteLine("include path:" + incPath); //} //dynamic propertySheet = vcConfig.PropertySheets; //IVCCollection propertySheetCollection = propertySheet as IVCCollection; //foreach (var item in propertySheetCollection) //{ // var vcPropertySheet = item as VCPropertySheet; // if (vcPropertySheet != null) // { // foreach(var rule in vcPropertySheet.Rules) // { // var vcRule = rule as IVCRulePropertyStorage; // if (vcRule != null) // { // vcRule.GetEvaluatedPropertyValue() // } // } // } //} //var config = vcProject.ActiveConfiguration; //if (config != null) //{ // var configProps = config.Properties; // var configPropIter = configProps.GetEnumerator(); // while (configPropIter.MoveNext()) // { // var configProp = configPropIter.Current as Property; // var configName = configProp.Name; // var configVal = ""; // try // { // configVal = configProp.Value.ToString(); // } // catch // { // } // Logger.WriteLine(" " + configName + ":" + configVal); // } // //Logger.WriteLine("group----------------------------"); // //var groups = config.OutputGroups; // //var groupIter = groups.GetEnumerator(); // //while (groupIter.MoveNext()) // //{ // // var group = groupIter.Current as OutputGroup; // // group. // //} //} } catch { Logger.Debug("project error-------------"); } return(true); }
/// <summary> /// Returns the value of a property that might not be supported by the current version of the compiler. /// If the property is not supported the default value is returned. /// </summary> /// <remarks>e.g. LanguageStandard is not supported by VS2015 so attempting to fetch the property will throw. /// We don't want the analysis to fail in that case so we'll catch the exception and return the default.</remarks> internal /* for testing */ static string GetPotentiallyUnsupportedPropertyValue(IVCRulePropertyStorage settings, string propertyName, string defaultValue) { try { return(settings.GetEvaluatedPropertyValue(propertyName)); } catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex)) { // Property was not found return(defaultValue); } }
public void ProjectFinishedGenerating(Project project) { try { ThreadHelper.ThrowIfNotOnUIThread(); GeneratePLCnCLIProject(); } catch (Exception e) { try { project.DTE.Solution.Remove(project); DeleteProjectDirectory(); DeleteSolutionFolderIfEmpty(project.DTE); } catch (Exception) {} throw e; } void GeneratePLCnCLIProject() { _project = project; VCProject p = _project.Object as VCProject; //**********create new plcncli project********** //**********get project type********** VCConfiguration configuration = p.ActiveConfiguration; IVCRulePropertyStorage plcnextRule = configuration.Rules.Item(Constants.PLCnextRuleName); if (plcnextRule == null) { throw new NullReferenceException("PLCnextCommonProperties rule was not found in configuration rules collection."); } string projectType = plcnextRule.GetUnevaluatedPropertyValue("ProjectType_"); string newProjectCommand = Resources.Command_new_plmproject; List <string> newProjectArguments = new List <string> { Resources.Option_new_project_output, $"\"{_projectDirectory}\"", Resources.Option_new_project_projectNamespace, _projectNamespace }; if (!projectType.Equals(Resources.ProjectType_ConsumableLibrary)) { newProjectArguments.Add(Resources.Option_new_project_componentName); newProjectArguments.Add(_componentName); if (projectType.Equals(Resources.ProjectType_PLM)) { newProjectArguments.Add(Resources.Option_new_project_programName); newProjectArguments.Add(_programName); } } if (projectType.Equals(Resources.ProjectType_ACF)) { newProjectCommand = Resources.Command_new_acfproject; } else if (projectType.Equals(Resources.ProjectType_ConsumableLibrary)) { newProjectCommand = Resources.Command_new_consumablelibrary; } _plcncliCommunication.ExecuteCommand(newProjectCommand, null, null, newProjectArguments.ToArray()); //**********create configurations********** ProjectConfigurationManager.CreateConfigurationsForAllProjectTargets (_projectTargets.Select(t => t.GetNameFormattedForCommandLine()), project); foreach (TargetResult target in _projectTargets) { //**********set project target********** _plcncliCommunication.ExecuteCommand(Resources.Command_set_target, null, null, Resources.Option_set_target_add, Resources.Option_set_target_name, target.Name, Resources.Option_set_target_version, target.Version, Resources.Option_set_target_project, $"\"{_projectDirectory}\""); } //add project items to project IEnumerable <string> projectFiles = Directory.GetFiles(_projectDirectory, "*.*pp", SearchOption.AllDirectories) .Concat(Directory.GetFiles(_projectDirectory, "*.txt", SearchOption.AllDirectories)) .Where(f => !f.EndsWith("UndefClang.hpp")); foreach (string file in projectFiles) { project.ProjectItems.AddFromFile(file); } //**********generate code********** _plcncliCommunication.ExecuteCommand(Resources.Command_generate_code, null, null, Resources.Option_generate_code_project, $"\"{_projectDirectory}\""); ProjectInformationCommandResult projectInformation = _plcncliCommunication.ExecuteCommand(Resources.Command_get_project_information, null, typeof(ProjectInformationCommandResult), Resources.Option_get_project_information_project, $"\"{_projectDirectory}\"") as ProjectInformationCommandResult; CompilerSpecificationCommandResult compilerSpecsCommandResult = _plcncliCommunication.ExecuteCommand(Resources.Command_get_compiler_specifications, null, typeof(CompilerSpecificationCommandResult), Resources.Option_get_compiler_specifications_project, $"\"{_projectDirectory}\"") as CompilerSpecificationCommandResult; ProjectIncludesManager.SetIncludesForNewProject(p, compilerSpecsCommandResult, projectInformation); } }
/// <summary> /// Reads any generic property from the current target properties. /// </summary> /// <param name="page">Name of the page where the property is located.</param> /// <param name="name">Name of the property.</param> /// <returns>The property requested.</returns> public virtual string GetProperty(string page, string name) { IVCRulePropertyStorage pageStorage = configuration_.Rules.Item(page); return(pageStorage.GetEvaluatedPropertyValue(name)); }