public string GetProjectProperty(Project dteProject, string propertyName, string configuration) { if (dteProject == null) { throw new ArgumentNullException(nameof(dteProject)); } if (string.IsNullOrWhiteSpace(propertyName)) { throw new ArgumentNullException(nameof(propertyName)); } string value = null; IVsHierarchy projectHierarchy = this.GetIVsHierarchy(dteProject); IVsBuildPropertyStorage propertyStorage = projectHierarchy as IVsBuildPropertyStorage; if (propertyStorage != null) { var hr = propertyStorage.GetPropertyValue(propertyName, configuration, (uint)_PersistStorageType.PST_PROJECT_FILE, out value); // E_XML_ATTRIBUTE_NOT_FOUND is returned when the property does not exist - this is OK. Debug.Assert(!ErrorHandler.Succeeded(hr) || hr != E_XML_ATTRIBUTE_NOT_FOUND, $"Failed to get the property '{propertyName}' for project '{dteProject.Name}'."); } else { Debug.Fail("Could not get IVsBuildPropertyStorage for EnvDTE.Project"); } return(value); }
public void ClearProjectProperty(Project dteProject, string propertyName) { if (dteProject == null) { throw new ArgumentNullException(nameof(dteProject)); } if (string.IsNullOrWhiteSpace(propertyName)) { throw new ArgumentNullException(nameof(propertyName)); } IVsHierarchy projectHierarchy = this.GetIVsHierarchy(dteProject); IVsBuildPropertyStorage propertyStorage = projectHierarchy as IVsBuildPropertyStorage; if (propertyStorage != null) { var hr = propertyStorage.RemoveProperty(propertyName, string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE); Debug.Assert(ErrorHandler.Succeeded(hr), $"Failed to remove property '{propertyName}' for project '{dteProject.Name}'."); } else { Debug.Fail("Could not get IVsBuildPropertyStorage for EnvDTE.Project"); } }
public bool TrySelectFile(Project project, string title, string filter, string storageKey, out string file) { IVsSolution solution = (IVsSolution)Dialog.ServiceProvider.GetService(typeof(SVsSolution)); IVsHierarchy hierarchy; if (!NativeMethods.Succeeded(solution.GetProjectOfUniqueName(project.FullName, out hierarchy))) { file = null; return(false); } // We want to read/persist the last directory location that was used if a key is provided. string lastSelectedFile = null; ProjectSettings settings = null; IVsBuildPropertyStorage storage = null; if (storageKey != null) { storage = hierarchy as IVsBuildPropertyStorage; } if (storage != null) { try { settings = new ProjectSettings(storage); lastSelectedFile = settings[storageKey]; } catch { // We don't want to fail scaffolding/selection if we have a settings issue. We'll just // ignore the settings entirely. settings = null; } } if (ProjectItemSelector.TrySelectItem(hierarchy, title, filter, lastSelectedFile, out file)) { if (settings != null) { try { settings[storageKey] = file; } catch { // We don't want to fail scaffolding/selection if we have a settings issue. We'll just // ignore the settings entirely. settings = null; } } return(true); } else { return(false); } }
/// <summary> /// Sets the known properties for the <see cref="ProjectItem"/> added to solution. /// </summary> /// <param name="projectItem"> /// A <see cref="ProjectItem"/> that represents the generated item in the solution. /// </param> /// <param name="output"> /// An <see cref="OutputFile"/> that holds metadata about the <see cref="ProjectItem"/> to be added to the solution. /// </param> private static void SetProjectItemBuildProperties(ProjectItem projectItem, OutputFile output) { if (output.BuildProperties.Count > 0) { // Get access to the build property storage service IServiceProvider serviceProvider = (IServiceProvider)Host; IVsSolution solution = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution)); IVsHierarchy hierarchy; ErrorHandler.ThrowOnFailure(solution.GetProjectOfUniqueName(projectItem.ContainingProject.UniqueName, out hierarchy)); IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage; if (buildPropertyStorage == null) { throw new TransformationException( string.Format( CultureInfo.CurrentCulture, "Project {0} does not support build properties required by {1}", projectItem.ContainingProject.Name, projectItem.Name)); } // Find the target project item in the property storage uint projectItemId; ErrorHandler.ThrowOnFailure(hierarchy.ParseCanonicalName(projectItem.get_FileNames(1), out projectItemId)); // Set build projerties for the target project item foreach (KeyValuePair <string, string> buildProperty in output.BuildProperties) { ErrorHandler.ThrowOnFailure(buildPropertyStorage.SetItemAttribute(projectItemId, buildProperty.Key, buildProperty.Value)); } } }
public static void SetGlobalProperty(this IVsBuildPropertyStorage propertyStorage, string propertyName, string value, string defaultValue) { if (string.IsNullOrEmpty(value) || value == defaultValue) { //propertyStorage.RemoveProperty( // propertyName, // string.Empty, // (uint)_PersistStorageType.PST_PROJECT_FILE); // Removing the value never works, so it's worse to leave it empty than to serialize the // default value, I think. propertyStorage.SetPropertyValue( propertyName, string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, defaultValue); } else { // Set the property with String.Empty condition to ensure it's global (not configuration scoped). propertyStorage.SetPropertyValue( propertyName, string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, value); } }
/// <summary> /// This method should be on the UI thread. The overrides should ensure that /// Sets NuGetPackageImportStamp to a new random guid. This is a hack to let the project system know it is out /// of date. /// The value does not matter, it just needs to change. /// </summary> protected static void UpdateImportStamp(EnvDTEProject envDTEProject) { Debug.Assert(ThreadHelper.CheckAccess()); IVsBuildPropertyStorage propStore = VsHierarchyUtility.ToVsHierarchy(envDTEProject) as IVsBuildPropertyStorage; if (propStore != null) { // <NuGetPackageImportStamp>af617720</NuGetPackageImportStamp> string stamp = Guid.NewGuid().ToString().Split('-')[0]; try { propStore.SetPropertyValue(NuGetImportStamp, string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, stamp); } catch (Exception ex1) { ExceptionHelper.WriteToActivityLog(ex1); } // Remove the NuGetImportStamp so that VC++ project file won't be updated with this stamp on disk, // which causes unnecessary source control pending changes. try { propStore.RemoveProperty(NuGetImportStamp, string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE); } catch (Exception ex2) { ExceptionHelper.WriteToActivityLog(ex2); } } }
public VsProjectFlavorCfg(VsProject project, IVsCfg baseCfg) { m_vsCfg = baseCfg; m_project = project; m_innerIVsDebuggableProjectCfg = m_vsCfg as IVsDebuggableProjectCfg; m_IVsBuildPropertyStorage = m_project as IVsBuildPropertyStorage; Debug.Assert(m_innerIVsDebuggableProjectCfg != null); m_connectionsDeployStatusCallback = new ConnectionPoint.Connections(); DeployPropertyPort = new ProjectBuildProperty("DeployTransport", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, DebugPort.NameFromPortFilter(PortFilter.Emulator)); DeployPropertyDevice = new ProjectBuildProperty("DeployDevice", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE); GenerateStubsFlag = new ProjectBuildPropertyBool("MF_GenerateStubs", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE); GenerateStubsRootName = new ProjectBuildProperty("MF_GenerateStubsRootName", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, "TARGET"); GenerateStubsDirectory = new ProjectBuildProperty("MF_GenerateStubsDirectory", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, "DIRECTORY"); try { ActivateDebugEngine(); } catch (Exception e) { VsPackage.MessageCentre.InternalErrorMsg(false, String.Format("Unable to register debug engine: {0}", e.Message)); } }
public static void SetProjectProperty(IVsSolution solution, Project project, string propertyName, string propertyValue, string configName, _PersistStorageType persistStorageType) { IVsHierarchy hierarchy = GetHierarchy(solution, project); IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage; buildPropertyStorage.SetPropertyValue(propertyName, configName, (uint)persistStorageType, propertyValue); }
public GlobalProjectProperties(ProjectNode project) { msBuildProject = project.As <Project>(); dteProject = project.As <EnvDTE.Project>(); vsBuild = project.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage; accessor = new DynamicPropertyAccessor(this); }
public PropertyExtender(IVsBuildPropertyStorage storage, uint itemId, IExtenderSite extenderSite, int cookie) { _storage = storage; _itemId = itemId; _extenderSite = extenderSite; _cookie = cookie; }
private static void GetBuildPropertyStorage(ProjectItem projectItem, out IVsBuildPropertyStorage propertyStorage, out uint projectItemId) { IVsHierarchy hierarchy = projectItem.ContainingProject.AsHierarchy(); propertyStorage = (IVsBuildPropertyStorage)hierarchy; ErrorHandler.ThrowOnFailure(hierarchy.ParseCanonicalName(projectItem.FileNames[1], out projectItemId)); }
public GrammarFileObjectExtenderProperties(IVsBuildPropertyStorage buildPropertyStorage, uint itemId) { Contract.Requires <ArgumentNullException>(buildPropertyStorage != null, "buildPropertyStorage"); _buildPropertyStorage = buildPropertyStorage; _itemId = itemId; }
/// <summary> /// Creates a new transformation file and adds it to the project. /// </summary> /// <param name="selectedProjectItem">The selected item to be transformed</param> /// <param name="itemName">Full name of the transformation file</param> /// <param name="projectPath">Full path to the current project</param> /// <param name="addDependentUpon">Wheter to add the new file dependent upon the source file</param> private void AddTransformFile(ProjectItem selectedProjectItem, string itemName, string projectPath, bool addDependentUpon) { try { string transformPath = Path.Combine(projectPath, itemName); string sourceFileName = selectedProjectItem.FileNames[1]; ITransformer transformer = TransformerFactory.GetTransformer(sourceFileName, null); transformer.CreateTransformFile(sourceFileName, transformPath, false); // Add the file to the project // If the DependentUpon metadata is required, add it under the original file // If not, add it to the project ProjectItem addedItem = addDependentUpon ? selectedProjectItem.ProjectItems.AddFromFile(transformPath) : selectedProjectItem.ContainingProject.ProjectItems.AddFromFile(transformPath); // We need to set the Build Action to None to ensure that it doesn't get published for web projects addedItem.Properties.Item("ItemType").Value = "None"; IVsHierarchy hierarchy = null; IVsProject vsProject = (IVsProject)hierarchy; IVsBuildPropertyStorage buildPropertyStorage = vsProject as IVsBuildPropertyStorage; if (buildPropertyStorage == null) { this.logger.LogMessage("Error obtaining IVsBuildPropertyStorage from hierarcy."); } } catch (Exception ex) { this.logger.LogMessage("AddTransformFile: Exception> " + ex.Message); } }
public GlobalProjectProperties(ProjectNode project) { msBuildProject = project.As<Project>(); dteProject = project.As<EnvDTE.Project>(); vsBuild = project.HierarchyNode.HierarchyIdentity.Hierarchy as IVsBuildPropertyStorage; accessor = new DynamicPropertyAccessor(this); }
public GrammarFileObjectExtenderProperties([NotNull] IVsBuildPropertyStorage buildPropertyStorage, uint itemId) { Requires.NotNull(buildPropertyStorage, nameof(buildPropertyStorage)); _buildPropertyStorage = buildPropertyStorage; _itemId = itemId; }
/// <summary> /// Initializes a new instance of the BuildIntegrationOptions class. /// </summary> /// <param name="project">The VS project.</param> public BuildIntegrationOptions(IVsBuildPropertyStorage project) { Param.RequireNotNull(project, "project"); this.project = project; this.InitializeComponent(); }
public void ConfigProperties() { using (PackageTestEnvironment testEnv = new PackageTestEnvironment()) { IVsBuildPropertyStorage buildProperty = testEnv.Project as IVsBuildPropertyStorage; Assert.IsNotNull(buildProperty, "Project does not implements IVsBuildPropertyStorage."); // Get (2 different configs) string propertyName = "ConfigProperty"; string value = null; int hr = buildProperty.GetPropertyValue(propertyName, "Debug", (uint)_PersistStorageType.PST_PROJECT_FILE, out value); Assert.AreEqual <int>(VSConstants.S_OK, hr, "GetPropertyValue failed"); Assert.AreEqual("DebugValue", value); hr = buildProperty.GetPropertyValue(propertyName, "Release", (uint)_PersistStorageType.PST_PROJECT_FILE, out value); Assert.AreEqual <int>(VSConstants.S_OK, hr, "GetPropertyValue failed"); Assert.AreEqual("ReleaseValue", value); // Set (with get to confirm) string newValue = "UpdatedConfig"; hr = buildProperty.SetPropertyValue(propertyName, "Debug", (uint)_PersistStorageType.PST_PROJECT_FILE, newValue); Assert.AreEqual <int>(VSConstants.S_OK, hr, "SetPropertyValue failed"); hr = buildProperty.GetPropertyValue(propertyName, "Debug", (uint)_PersistStorageType.PST_PROJECT_FILE, out value); Assert.AreEqual <int>(VSConstants.S_OK, hr, "GetPropertyValue failed"); Assert.AreEqual(newValue, value); } }
/// <summary> /// Verifies if the item has a trasform configured already /// </summary> /// <param name="vsProject">The current project</param> /// <param name="itemid">The id of the selected item inside the project</param> /// <returns>True if the item has a transform</returns> private bool IsItemTransformItem(IVsProject vsProject, uint itemid) { IVsBuildPropertyStorage buildPropertyStorage = vsProject as IVsBuildPropertyStorage; if (buildPropertyStorage == null) { this.LogMessageWriteLineFormat("Error obtaining IVsBuildPropertyStorage from hierarcy."); return(false); } string value; buildPropertyStorage.GetItemAttribute(itemid, IsTransformFile, out value); bool valueAsBool; if (bool.TryParse(value, out valueAsBool) && valueAsBool) { return(true); } // we need to special case web.config transform files string filePath; buildPropertyStorage.GetItemAttribute(itemid, "FullPath", out filePath); IEnumerable <string> configs = ProjectUtilities.GetProjectConfigurations(vsProject as IVsHierarchy); // If the project is a web app, check for the Web.config files added by default return(ProjectUtilities.IsProjectWebApp(vsProject) && PackageUtilities.IsFileTransform("web.config", Path.GetFileName(filePath), configs)); }
/// <summary> /// Creates a new XML transformation file and adds it to the project. /// </summary> /// <param name="selectedProjectItem">The selected item to be transformed</param> /// <param name="content">Contents to be written to the transformation file</param> /// <param name="itemName">Full name of the transformation file</param> /// <param name="projectPath">Full path to the current project</param> private void AddXdtTransformFile(ProjectItem selectedProjectItem, string content, string itemName, string projectPath) { try { string itemPath = Path.Combine(projectPath, itemName); if (!File.Exists(itemPath)) { // create the new XDT file using (StreamWriter writer = new StreamWriter(itemPath)) { writer.Write(content); } } // and add it to the project ProjectItem addedItem = selectedProjectItem.ProjectItems.AddFromFile(itemPath); // we need to set the Build Action to None to ensure that it doesn't get published for web projects addedItem.Properties.Item("ItemType").Value = "None"; IVsHierarchy hierarchy = null; IVsProject vsProject = (IVsProject)hierarchy; IVsBuildPropertyStorage buildPropertyStorage = vsProject as IVsBuildPropertyStorage; if (buildPropertyStorage == null) { this.LogMessageWriteLineFormat("Error obtaining IVsBuildPropertyStorage from hierarcy."); } } catch (Exception ex) { this.LogMessageWriteLineFormat("AddTransformFile: Exception> " + ex.Message); } }
void SetBuildProperties(string inputFileName, ProjectItem item) { Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { string uniqueName = item.ContainingProject.UniqueName; IVsSolution solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); IVsHierarchy hierarchy; solution.GetProjectOfUniqueName(uniqueName, out hierarchy); IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage; if (buildPropertyStorage != null) { string fullPath = Path.ChangeExtension(inputFileName, GetDefaultExtension()); uint itemId; hierarchy.ParseCanonicalName(fullPath, out itemId); buildPropertyStorage.SetItemAttribute(itemId, "MergeWithCTO", "true"); buildPropertyStorage.SetItemAttribute(itemId, "ManifestResourceName", "VSPackage"); } }), DispatcherPriority.ApplicationIdle, null); }
public void TestGlobalPropertyMatch() { UIThreadInvoker.Invoke((ThreadInvoker) delegate() { //Get the global service provider and the dte IServiceProvider sp = VsIdeTestHostContext.ServiceProvider; DTE dte = (DTE)sp.GetService(typeof(DTE)); string destination = Path.Combine(TestContext.TestDir, TestContext.TestName); ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true); Microsoft.Build.BuildEngine.Project buildProject = typeof(ProjectNode).GetProperty("BuildProject", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(project, new object[] { }) as Microsoft.Build.BuildEngine.Project; IVsHierarchy nestedProject = Utilities.GetNestedHierarchy(project, "ANestedProject"); IVsBuildPropertyStorage nestedProjectPropertyStorage = nestedProject as IVsBuildPropertyStorage; foreach (string property in Enum.GetNames(typeof(GlobalProperty))) { string nestedProjectGlobalProperty; // We will pass in the debug configuration since the GetPropertyValue will change the global property to whatever does not exist as configuration like empty or null. nestedProjectPropertyStorage.GetPropertyValue(property, "Debug", (uint)_PersistStorageType.PST_PROJECT_FILE, out nestedProjectGlobalProperty); string parentProjectGlobalProperty = buildProject.GlobalProperties[property].Value; bool result; bool isBoolean = (Boolean.TryParse(parentProjectGlobalProperty, out result) == true); Assert.IsTrue(String.Compare(nestedProjectGlobalProperty, parentProjectGlobalProperty, isBoolean ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == 0, "The following global Properties do not match for Property: " + property + " Nested :" + nestedProjectGlobalProperty + " Parent:" + parentProjectGlobalProperty); } }); }
public PropertyExtender(IVsBuildPropertyStorage storage, uint itemId, IExtenderSite extenderSite, int cookie) { this.storage = storage; this.itemId = itemId; this.extenderSite = extenderSite; this.cookie = cookie; }
public NoneItemExtender(IVsHierarchy hierarchy, uint item, IExtenderSite site, int cookie) { propertyStorage = (IVsBuildPropertyStorage)hierarchy; this.item = item; this.site = site; this.cookie = cookie; }
public GrammarFileObjectExtenderProperties(IVsBuildPropertyStorage buildPropertyStorage, uint itemId) { Contract.Requires<ArgumentNullException>(buildPropertyStorage != null, "buildPropertyStorage"); _buildPropertyStorage = buildPropertyStorage; _itemId = itemId; }
public void GlobalProperties() { using (PackageTestEnvironment testEnv = new PackageTestEnvironment()) { IVsBuildPropertyStorage buildProperty = testEnv.Project as IVsBuildPropertyStorage; Assert.IsNotNull(buildProperty, "Project does not implements IVsBuildPropertyStorage."); // Get string propertyName = "GlobalProperty"; string value = null; int hr = buildProperty.GetPropertyValue(propertyName, null, (uint)_PersistStorageType.PST_PROJECT_FILE, out value); Assert.AreEqual <int>(VSConstants.S_OK, hr, "GetPropertyValue failed"); Assert.AreEqual("Global", value); // Set (with get to confirm) string newValue = "UpdatedGlobal"; hr = buildProperty.SetPropertyValue(propertyName, null, (uint)_PersistStorageType.PST_PROJECT_FILE, newValue); Assert.AreEqual <int>(VSConstants.S_OK, hr, "SetPropertyValue failed"); hr = buildProperty.GetPropertyValue(propertyName, null, (uint)_PersistStorageType.PST_PROJECT_FILE, out value); Assert.AreEqual <int>(VSConstants.S_OK, hr, "GetPropertyValue failed"); Assert.AreEqual(newValue, value); // Remove (with get to confirm) hr = buildProperty.RemoveProperty(propertyName, null, (uint)_PersistStorageType.PST_PROJECT_FILE); Assert.AreEqual <int>(VSConstants.S_OK, hr, "RemoveProperty failed"); hr = buildProperty.GetPropertyValue(propertyName, null, (uint)_PersistStorageType.PST_PROJECT_FILE, out value); Assert.AreEqual <int>(VSConstants.S_OK, hr, "GetPropertyValue failed"); Assert.AreEqual(String.Empty, value); } }
/// <summary> /// Deletes a property from the project's .user file. /// </summary> /// <param name="project">The project to delete the property from.</param> /// <param name="propertyName">The name of the property to delete.</param> public void DeleteUserProperty(Project project, string propertyName) { ThreadHelper.ThrowIfNotOnUIThread(); IVsBuildPropertyStorage propertyStore = GetProjectPropertyStore(project); ErrorHandler.ThrowOnFailure( propertyStore.RemoveProperty(propertyName, null, UserFileFlag)); }
void IVsProjectCfgDebugTargetSelection.GetCurrentDebugTarget(out Guid pguidDebugTargetType, out uint pDebugTargetTypeId, out string pbstrCurrentDebugTarget) { IVsBuildPropertyStorage bps = this; pguidDebugTargetType = VSConstants.AppPackageDebugTargets.guidAppPackageDebugTargetCmdSet; pDebugTargetTypeId = VSConstants.AppPackageDebugTargets.cmdidAppPackage_RemoteMachine; pbstrCurrentDebugTarget = RemoteTarget; }
protected override void OnRun(DebuggerStartInfo startInfo) { base.OnRun(startInfo); UseOperationThread = true; Project startupProject = ((Mono.Debugging.VisualStudio.StartInfo)startInfo).StartupProject; IVsHierarchy hierarchy = startupProject.ToHierarchy(); IProjectNode node = startupProject.AsProjectNode(); BuildPropertyStorage storage = new BuildPropertyStorage(hierarchy, node.Configuration.ActiveConfigurationName); var enableAotMode = storage.GetPropertyValue <bool>(XamarinWindowsConstants.EnableAotModeProperty); var bundleAsemblies = storage.GetPropertyValue <bool>(XamarinWindowsConstants.BundleAssembliesProperty); var generateDebuggableAotModules = storage.GetPropertyValue <bool>(XamarinWindowsConstants.GenerateDebuggableAotModulesProperty); var additionalMonoOptions = storage.GetPropertyValue <string>(XamarinWindowsConstants.AdditionalMonoOptionsProperty)?.Trim(); var monoLogLevel = storage.GetPropertyValue <string>(XamarinWindowsConstants.MonoLogLevelProperty); var monoLogMask = storage.GetPropertyValue <string>(XamarinWindowsConstants.MonoLogMaskProperty); var startArguments = startupProject.ConfigurationManager.ActiveConfiguration.Properties.Item("StartArguments").Value.ToString(); var assemblyPath = GetOutputAssembly(startupProject, enableAotMode, generateDebuggableAotModules); var monoDirectory = Path.Combine(GetInstallPath(), @"MSBuild\Xamarin\Windows\x64\Release"); var monoPath = Path.Combine(GetInstallPath(), @"Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.Windows\v1.0"); var args = ((Mono.Debugging.VisualStudio.StartInfo)startInfo).StartArgs as SoftDebuggerListenArgs; process = new System.Diagnostics.Process(); var workingDirectory = Path.GetDirectoryName(assemblyPath); var monoOptions = $"--debug --debugger-agent=transport=dt_socket,address=127.0.0.1:{args.DebugPort}"; if (!string.IsNullOrEmpty(additionalMonoOptions)) { monoOptions += " " + additionalMonoOptions; } if (!enableAotMode) { process.StartInfo = new ProcessStartInfo(Path.Combine(monoDirectory, "mono-sgen.exe"), monoOptions + $" \"{assemblyPath}\" {startArguments}".TrimEnd()); } else { IVsBuildPropertyStorage buildPropertyStorage = (IVsBuildPropertyStorage)hierarchy; string nativeProjectName = buildPropertyStorage.GetMSBuildPropertyValue("_XWNativeProjectName", null); var launcherExe = Path.Combine(workingDirectory, nativeProjectName + ".exe"); process.StartInfo = new ProcessStartInfo(launcherExe, startArguments); process.StartInfo.EnvironmentVariables["MONO_BUNDLED_OPTIONS"] = monoOptions; } process.StartInfo.WorkingDirectory = workingDirectory; process.StartInfo.UseShellExecute = false; if (!string.IsNullOrEmpty(monoLogLevel)) { process.StartInfo.EnvironmentVariables["MONO_LOG_LEVEL"] = monoLogLevel; } if (!string.IsNullOrEmpty(monoLogMask)) { process.StartInfo.EnvironmentVariables["MONO_LOG_MASK"] = monoLogMask; } process.StartInfo.EnvironmentVariables["MONO_PATH"] = monoPath; process.Start(); }
public ProjectPropertyStorage(IVsBuildPropertyStorage storage) { if (storage == null) { throw new ArgumentNullException("storage"); } _storage = storage; }
public AssemblyReferenceExtender(EnvDTE.IExtenderSite extenderSite, int cookie, VSLangProj.Reference reference, IVsBuildPropertyStorage storage, uint itemId) { _extenderSite = extenderSite; _cookie = cookie; _storage = storage; _itemid = itemId; Reference = reference; }
public ItemProperties(ItemNode item) { this.node = item.HierarchyNode; this.item = item.HierarchyNode.ExtensibilityObject as ProjectItem; this.msBuild = item.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage; if (System.Diagnostics.Debugger.IsAttached) debugString = string.Join(Environment.NewLine, GetDynamicMemberNames() .Select(name => name + "=" + GetValue(name))); }
int IVsBuildPropertyStorage.SetPropertyValue(string propertyName, string configName, uint storage, string propertyValue) { IVsBuildPropertyStorage cfg = _innerCfg as IVsBuildPropertyStorage; if (cfg != null) { return(cfg.SetPropertyValue(propertyName, configName, storage, propertyValue)); } return(VSConstants.S_OK); }
public static void SetProjectItemProperty(IVsSolution solution, ProjectItem projectItem, string propertyName, string propertyValue) { IVsHierarchy hierarchy = GetHierarchy(solution, projectItem.ContainingProject); IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage; uint itemId; string fullPath = (string)projectItem.Properties.Item("FullPath").Value; hierarchy.ParseCanonicalName(fullPath, out itemId); buildPropertyStorage.SetItemAttribute(itemId, propertyName, propertyValue); }
public ConfigProjectProperties(ProjectNode project, string configName) { this.project = project; this.configName = configName; vsBuild = project.HierarchyNode.HierarchyIdentity.Hierarchy as IVsBuildPropertyStorage; if (vsBuild == null) tracer.Warn(Strings.ConfigProjectProperties.NonMsBuildProject(project.Text)); accessor = new DynamicPropertyAccessor(this); }
public UserProjectProperties(ProjectNode project) { this.project = project; msBuildProject = project.As<Project>(); dteProject = project.As<EnvDTE.Project>(); vsBuild = project.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage; if (msBuildProject == null || vsBuild == null) tracer.Warn(Strings.UserProjectProperties.NonMsBuildProject(project.DisplayName)); accessor = new DynamicPropertyAccessor(this); }
internal BrowseObjectExtender(IServiceProvider serviceProvider, IVsBrowseObject browseObject, IExtenderSite site, int cookie) { Debug.Assert(serviceProvider != null, "serviceProvider"); Debug.Assert(browseObject != null, "browseObject"); Debug.Assert(site != null, "site"); Debug.Assert(cookie != 0, "cookie"); this.site = site; this.cookie = cookie; this.serviceProvider = serviceProvider; ErrorHandler.ThrowOnFailure(browseObject.GetProjectItem(out this.hierarchy, out this.itemId)); this.propertyStorage = (IVsBuildPropertyStorage)this.hierarchy; this.CustomToolParameters = new CustomToolParameters(this.serviceProvider, this.hierarchy, this.itemId); }
/// <summary> /// Use the data passed in to initialize ourselve /// </summary> /// <param name="dataObject">This is normally our configuration object or null when we should release it</param> public void Initialize(object[] dataObjects) { // If we are editing multiple configuration at once, we may get multiple objects foreach (object dataObject in dataObjects) { var browseObject = dataObject as IVsBrowseObject; if (browseObject != null) { IVsHierarchy hierarchy; uint item; browseObject.GetProjectItem(out hierarchy, out item); buildStorage = (IVsBuildPropertyStorage)hierarchy; } } }
public ProjectBuildProperty(string propName, IVsBuildPropertyStorage storage, VsProjectFlavorCfg cfg, _PersistStorageType type, _PersistStorageType typeDefault, string valDefault) { m_propName = propName; m_storage = storage; m_cfg = cfg; m_type = type; m_fPropertyLoaded = false; m_valDefault = valDefault; m_typeDefault = typeDefault; }
private bool ValidateSlowCheetahTargetsAvailable(IVsBuildPropertyStorage buildPropertyStorage, string projectFullPath, string importPath, out bool addImports) { addImports = false; string importsExpression = string.Format("$({0})",Settings.Default.SlowCheetahTargets); #if USE_SLOWCHEETAH_TARGET_PROPERTY_FOR_IMPORT if (!IsSlowCheetahImported(buildPropertyStorage)) { #else if (IsSlowCheetahImported(projectFullPath, importsExpression)) { #endif return true; } if (HasUserAcceptedWarningMessage(projectFullPath, importPath)) { addImports = true; return true; } return false; } /// <summary> /// Checks the project file to see if the appropriate import has been made to slow Cheetah. /// </summary> /// <param name="buildPropertyStorage">Project's build property storage interface.</param> /// <returns>True if the SlowCheetah import is in the project file; otherwise false.</returns> #if USE_SLOWCHEETAH_TARGET_PROPERTY_FOR_IMPORT private bool IsSlowCheetahImported(IVsBuildPropertyStorage buildPropertyStorage) { // check to see if the SlowCheetahImport property is set to true by the import file string propertyValue; buildPropertyStorage.GetPropertyValue(Resources.String_SlowCheetahImportProp, "|", (uint) _PersistStorageType.PST_PROJECT_FILE, out propertyValue); if (!string.IsNullOrWhiteSpace(propertyValue)) { // this property is assigned the value of $(MSBuildThisFileFullPath), which sets it to the import path of the SlowCheetah targets file // this is to make checking of the import fast and efficient, since this is not currently supported by VS return true; } return false; }
protected override void SetInnerProject(IntPtr innerIUnknown) { // // This was changed to support VS2012 - The FlavoredProject base class we were using // was throwing a COM exception, so we switched to use the newer FlavoredProjectBase class // which uses an IntPtr instead of a managed object for this class. The following method // converts the IUnknown IntPtr into a managed object from which we can convert into the // following interfaces. // object inner = Marshal.GetUniqueObjectForIUnknown(innerIUnknown); m_innerIVsProject = inner as IVsProject; m_innerIVsProjectBuildSystem = inner as IVsProjectBuildSystem; m_innerIVsHierarchy = inner as IVsHierarchy; m_innerIVsUIHierarchy = inner as IVsUIHierarchy; m_innerSingleFileGeneratorFactory = inner as IVsSingleFileGeneratorFactory; m_innerIVsBuildPropertyStorage = inner as IVsBuildPropertyStorage; m_innerProjectSpecialFiles = inner as IVsProjectSpecialFiles; Debug.Assert(m_innerIVsProject != null); Debug.Assert(m_innerIVsProjectBuildSystem != null); Debug.Assert(m_innerIVsHierarchy != null); Debug.Assert(m_innerIVsUIHierarchy != null); Debug.Assert(m_innerSingleFileGeneratorFactory != null); Debug.Assert(m_innerIVsBuildPropertyStorage != null); Debug.Assert(m_innerProjectSpecialFiles != null); if (this.serviceProvider == null) { this.serviceProvider = (System.IServiceProvider)this.m_package; } base.SetInnerProject(innerIUnknown); }
public ProjectBuildProperty(string propName, IVsBuildPropertyStorage storage, VsProjectFlavorCfg cfg, _PersistStorageType type) : this(propName, storage, cfg, type, PersistStorageTypeNone, string.Empty) { }
public ProjectBuildPropertyBool(string propName, IVsBuildPropertyStorage storage, VsProjectFlavorCfg cfg, _PersistStorageType type) : base (propName, storage, cfg, type) { }
internal void GetProjectItem(out IVsBuildPropertyStorage project, out uint itemId) { project = (IVsBuildPropertyStorage)this.project; itemId = this.projectItemId; }
public ProjectProperties(ProjectNode project) { dteProject = project.m_dteProject; vsBuild = project.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage; }
public ProjectSettings(IVsBuildPropertyStorage storage) { Contract.Assert(storage != null); Storage = storage; }
private static void GetProjectItem(object component, out IVsBuildPropertyStorage project, out uint itemId) { if (component == null) { throw new ArgumentNullException("component"); } var parent = component as CustomToolParameters; if (parent == null) { throw new ArgumentException( string.Format( CultureInfo.CurrentCulture, "Object of type {0} is expected, actual object is of type {1}.", typeof(CustomToolParameters).FullName, component.GetType().FullName), "component"); } parent.GetProjectItem(out project, out itemId); }
public ItemProperties (ItemNode item) { this.item = item.HierarchyNode.GetExtenderObject () as ProjectItem; node = item.HierarchyNode; msBuild = item.HierarchyNode.GetRoot ().HierarchyIdentity.Hierarchy as IVsBuildPropertyStorage; }
private void SetBuildStorage() { // Get the build storage associated with this property page. buildStorage = null; if (configs != null) { foreach (object config in configs) { if (config != null) { // try to retrieve the project using IVs(Cfg)BrowseObject IVsHierarchy project = null; IVsBrowseObject browse = config as IVsBrowseObject; if (browse != null) { uint itemid; browse.GetProjectItem(out project, out itemid); } else { IVsCfgBrowseObject cfgBrowse = config as IVsCfgBrowseObject; if (cfgBrowse != null) { uint itemid; cfgBrowse.GetProjectItem(out project, out itemid); } } // try to cast the project to a buildstorage buildStorage = project as IVsBuildPropertyStorage; if (buildStorage != null) { return; // we are done. } } } } }
public void SetObjects(uint cObjects, object[] ppunk) { configs = null; configNames = null; buildStorage = null; if (pane != null && ppunk != null) { configs = ppunk; SetBuildStorage(); SetConfigurationNames(); initializing = true; pane.LoadProperties(configNames, this); initializing = false; SetDirty(false); } }