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); } }
private void CommitCommandLineText(string CommandLine) { IVsHierarchy ProjectHierarchy; if (UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null) { Project SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy); if (SelectedStartupProject != null) { Configuration SelectedConfiguration = SelectedStartupProject.ConfigurationManager.ActiveConfiguration; if (SelectedConfiguration != null) { IVsBuildPropertyStorage PropertyStorage = ProjectHierarchy as IVsBuildPropertyStorage; if (PropertyStorage != null) { string FullCommandLine = CommandLine; // for "Game" projects automatically remove the game project filename from the start of the command line var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration; if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name)) { string AutoPrefix = Utils.GetAutoUProjectCommandLinePrefix(SelectedStartupProject); if (FullCommandLine.IndexOf(Utils.UProjectExtension, StringComparison.OrdinalIgnoreCase) < 0 && string.Compare(FullCommandLine, SelectedStartupProject.Name, StringComparison.OrdinalIgnoreCase) != 0 && !FullCommandLine.StartsWith(SelectedStartupProject.Name + " ", StringComparison.OrdinalIgnoreCase)) { // Committed command line does not specify a .uproject FullCommandLine = AutoPrefix + " " + FullCommandLine; } } // Get the project kind. C++ projects store the debugger arguments differently to other project types. string ProjectKind = SelectedStartupProject.Kind; // Update the property string ProjectConfigurationName = String.Format("{0}|{1}", SelectedConfiguration.ConfigurationName, SelectedConfiguration.PlatformName); if (String.Equals(ProjectKind, "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}", StringComparison.InvariantCultureIgnoreCase)) { PropertyStorage.SetPropertyValue("LocalDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine); } else { PropertyStorage.SetPropertyValue("StartArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine); } } } } } CommitCommandLineToMRU(CommandLine); }
public void SetProjectProperty(Project dteProject, string propertyName, string value) { 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.SetPropertyValue(propertyName, string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, value); Debug.Assert(ErrorHandler.Succeeded(hr), $"Failed to set property '{propertyName}' to '{value}' for project '{dteProject.Name}'."); } else { Debug.Fail("Could not get IVsBuildPropertyStorage for EnvDTE.Project"); } }
/// <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 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); }
bool IPropertyAccessor.TrySetProperty(string propertyName, object value) { if (TrySetDteProperty(propertyName, value)) { return(true); } if (this.vsBuild != null) { if (ErrorHandler.Succeeded(vsBuild.SetPropertyValue( propertyName, "", (uint)_PersistStorageType.PST_PROJECT_FILE, value.ToString()))) { return(true); } } if (this.msBuildProject != null) { this.msBuildProject.SetProperty(propertyName, value.ToString()); return(true); } // In this case we fail, since we can't persist the member. return(false); }
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); } }
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); } }
public int SetProperty(bool perUser, string configName, string propertyName, object value) { if (value == null) { return(0); } int hr; // first try to set it on the config object directly object config = GetConfigObject(configName); if (config != null) { hr = SetDynamicProperty(propertyName, value, config); if (hr == 0) { return(hr); } } // otherwise, set it on the build storage if (buildStorage != null) { hr = buildStorage.SetPropertyValue(propertyName, configName , (uint)(perUser ? _PersistStorageType.PST_USER_FILE : _PersistStorageType.PST_PROJECT_FILE) , value.ToString()); return(hr); } else { return(VSConstants.E_FAIL); } }
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); }
private void menuItem1_Click(object sender, MenuItemEventArgs e) { ISharePointProject project = (ISharePointProject)e.Owner; //<Snippet13> IVsBuildPropertyStorage projectStorage = project.ProjectService.Convert <ISharePointProject, IVsBuildPropertyStorage>(project); projectStorage.SetPropertyValue("MyCustomProperty", string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, "Custom property value"); //</Snippet13> }
/// <summary> /// Set the value of the specified property in storage. /// </summary> /// <param name="propertyName">Name of the property to set.</param> /// <param name="propertyValue">Value to set the property to.</param> public void SetPropertyValue(string propertyName, string propertyValue) { // Handle multiple properties string[] propertyNames = propertyName.Split(','); string[] propertyValues; if (propertyValue == null) { propertyValues = new string[propertyNames.Length]; for (int i = 0; i < propertyNames.Length; i++) { propertyValues[i] = string.Empty; } } else { propertyValues = propertyValue.Split(','); } if (configs == null) { for (int i = 0; i < propertyNames.Length; i++) { ErrorHandler.ThrowOnFailure(buildPropStorage.SetPropertyValue(propertyNames[i], String.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, propertyValues[i])); } } else { foreach (string config in configs) { for (int i = 0; i < propertyNames.Length; i++) { ErrorHandler.ThrowOnFailure(buildPropStorage.SetPropertyValue(propertyNames[i], config, (uint)_PersistStorageType.PST_PROJECT_FILE, propertyValues[i])); } } } if (StoreChanged != null) { StoreChanged(); } }
public void CommitChanges() { foreach (var kvp in pendingValuesToBePersisted) { vsBuildPropertyStorage.SetPropertyValue( kvp.Key, null, (uint)_PersistStorageType.PST_PROJECT_FILE, kvp.Value.ToString()); } pendingValuesToBePersisted.Clear(); }
/// <summary> /// 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, bool isCpsProjectSystem = false) { // There is no reason to call this for pre-Dev12 project systems. if (VSVersionHelper.VsMajorVersion >= 12) { #if VS14 // Switch to UI thread to update Import Stamp for Dev14. if (isCpsProjectSystem && VSVersionHelper.IsVisualStudio2014) { try { var projectServiceAccessor = ServiceLocator.GetInstance <IProjectServiceAccessor>(); ProjectService projectService = projectServiceAccessor.GetProjectService(); IThreadHandling threadHandling = projectService.Services.ThreadingPolicy; threadHandling.SwitchToUIThread(); } catch (Exception ex) { ExceptionHelper.WriteToActivityLog(ex); } } #endif IVsBuildPropertyStorage propStore = VsHierarchyUtility.ToVsHierarchy(envDTEProject) as IVsBuildPropertyStorage; if (propStore != null) { // <NuGetPackageImportStamp>af617720</NuGetPackageImportStamp> string stamp = Guid.NewGuid().ToString().Split('-')[0]; try { int r1 = 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 { int r2 = propStore.RemoveProperty(NuGetImportStamp, string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE); } catch (Exception ex2) { ExceptionHelper.WriteToActivityLog(ex2); } } } }
/// <summary> /// 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(Project project) { // There is no reason to call this for pre-Dev12 project systems. if (VsVersionHelper.IsVisualStudio2013) { IVsBuildPropertyStorage propStore = project.ToVsHierarchy() as IVsBuildPropertyStorage; if (propStore != null) { // <NuGetPackageImportStamp>af617720</NuGetPackageImportStamp> string stamp = Guid.NewGuid().ToString().Split('-')[0]; ErrorHandler.ThrowOnFailure(propStore.SetPropertyValue("NuGetPackageImportStamp", string.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, stamp)); } } }
public static void SetProjectID(int projectId, string uniqueName) { if (string.IsNullOrEmpty(uniqueName)) { return; } IVsHierarchy hierarchy; IVsSolution solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); solution.GetProjectOfUniqueName(uniqueName, out hierarchy); IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage; buildPropertyStorage.SetPropertyValue("QCProjectID", String.Empty, (uint)_PersistStorageType.PST_PROJECT_FILE, projectId.ToString()); }
bool IPropertyAccessor.TrySetProperty(string propertyName, object value) { if (vsBuild != null) { return(ErrorHandler.Succeeded(vsBuild.SetPropertyValue( propertyName, configName, (uint)_PersistStorageType.PST_PROJECT_FILE, value.ToString()))); } else { tracer.Warn(Strings.ConfigProjectProperties.SetNonMsBuildProject(propertyName, configName, project.Text)); } // In this case we fail, since we can't persist the member. return(false); }
bool IPropertyAccessor.TrySetProperty(string propertyName, object value) { if (this.vsBuild != null) { if (ErrorHandler.Succeeded(vsBuild.SetPropertyValue( propertyName, "", (uint)_PersistStorageType.PST_USER_FILE, value.ToString()))) return true; } else { tracer.Warn(Strings.UserProjectProperties.SetNonMsBuildProject(propertyName, project.DisplayName)); } // In this case we fail, since we can't persist the member. return false; }
/// <summary> /// Saves a property to the project's .user file. /// </summary> /// <param name="project">The project to save the property to.</param> /// <param name="propertyName">The name of the property to save.</param> /// <param name="value">The value of the property.</param> public void SaveUserProperty(Project project, string propertyName, string value) { ThreadHelper.ThrowIfNotOnUIThread(); IVsBuildPropertyStorage propertyStore = GetProjectPropertyStore(project); int hr; if (value == null) { hr = propertyStore.RemoveProperty(propertyName, null, UserFileFlag); } else { hr = propertyStore.SetPropertyValue(propertyName, null, UserFileFlag, value); } ErrorHandler.ThrowOnFailure(hr); }
private int SetProjectProperty(string name, string value) { return(_storage.SetPropertyValue(name, "", storageType, value ?? "")); }
public void RunFinished() { Project silverlightProject = this.GetSilverlightProject(); // Here we create the web project from template. // The location of web template is calculated as a relative path from current(client) template, // which is passed as customParams[0] in current version of VS/VWD(undocumented). if (this._customParams.Length > 0 && this._customParams[0] != null) { string templateDir = Path.GetDirectoryName((string)this._customParams[0]); #if VS10 string webTemplateDir = Path.Combine(templateDir, "BA.Web.10.0"); #else string webTemplateDir = Path.Combine(templateDir, "BA.Web"); #endif if (!Directory.Exists(webTemplateDir)) { // In V1 SP1, we switched to a shorter directory name to avoid a lot of messy path-length // issues. However, some older templates might still have the original directory name. webTemplateDir = Path.Combine(templateDir, "BusinessApplication.Web"); } string webTemplate = Path.Combine(webTemplateDir, "server.vstemplate"); // CSDMain 228876 // Custom parameters can be appended to the path when calling AddFromTemplate. We need to use something other than // $targetframeworkversion$ since we're not calling GetProjectTemplate and $targetframeworkversion$ is already baked in // as the default when calling AddFromTemplate in this manner. The project file and web.config reference // $targetwebframeworkversion$ to complete this. webTemplate += "|$targetwebframeworkversion$=" + this._replacementsDictionary["$targetframeworkversion$"]; string destination = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(silverlightProject.FullName)), this._webProjectName); this._solution2.AddFromTemplate(webTemplate, destination, this._webProjectName, false); } Project webProject = this.GetWebProject(); if (webProject != null) { // Set the WAP as the startup project this._dte2.Solution.SolutionBuild.StartupProjects = webProject.UniqueName; Properties props = webProject.Properties; // Set the start page ProjectItem testPageItem = this.GetAspxTestPage(webProject); if (testPageItem != null) { props.Item("WebApplication.StartPageUrl").Value = testPageItem.Name; props.Item("WebApplication.DebugStartAction").Value = 1; // StartAction.SpecificPage } // Link the server project to the client if (silverlightProject != null) { string projectReference = webProject.FullName; if ((webProject.FullName.Length > 0) && Path.IsPathRooted(webProject.FullName)) { projectReference = MakeProjectPathRelative(projectReference, silverlightProject.FullName); } IVsSolution ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); IVsHierarchy hierarchy; ivsSolution.GetProjectOfUniqueName(silverlightProject.UniqueName, out hierarchy); IVsBuildPropertyStorage buildPropertyStorage = (IVsBuildPropertyStorage)hierarchy; buildPropertyStorage.SetPropertyValue("LinkedOpenRiaServerProject", null, (uint)_PersistStorageType.PST_PROJECT_FILE, projectReference); buildPropertyStorage.SetPropertyValue("DisableFastUpToDateCheck", null, (uint)_PersistStorageType.PST_PROJECT_FILE, "true"); // Add this client to the list of clients in the server project // Get the IVsHierarchy for each one from the solution IOleServiceProvider oleServiceProvider = this._dte2 as IOleServiceProvider; IVsSolution sln = null; using (ServiceProvider sp = new ServiceProvider(oleServiceProvider)) { // Get the solution sln = sp.GetService(typeof(IVsSolution)) as IVsSolution; System.Diagnostics.Debug.Assert(sln != null, "Unable to get solution object."); } // Get the hierarchies for each project IVsHierarchy webHierarchy; int result; result = sln.GetProjectOfUniqueName(webProject.UniqueName, out webHierarchy); System.Diagnostics.Debug.Assert(result == 0, "Unexpected failure."); if (result == 0 && webHierarchy != null) { IVsHierarchy silverlightHierarchy; result = sln.GetProjectOfUniqueName(silverlightProject.UniqueName, out silverlightHierarchy); System.Diagnostics.Debug.Assert(result == 0, "Unexpected failure."); if (result == 0) { //// Cast the server one to a silverlight project consumer //IVsSilverlightProjectConsumer spc = webHierarchy as IVsSilverlightProjectConsumer; //// Create the Silverlight link //spc.LinkToSilverlightProject("ClientBin", // destination folder // true, //enable silverlight debugging // false, //use cfg specific folders // silverlightHierarchy as IVsSilverlightProject); } } } } // Add Links to .resx files FileInfo webProjectProjectFile = new FileInfo(webProject.FullName); string webProjectDirectory = webProjectProjectFile.DirectoryName; ProjectItem webResourcesFolder = silverlightProject.ProjectItems.AddFolder("Web", null).ProjectItems.AddFolder("Resources", null); foreach (string resxFile in Directory.GetFiles(Path.Combine(webProjectDirectory, "Resources"), "*.resx")) { ProjectItem link = webResourcesFolder.ProjectItems.AddFromFile(resxFile); link.Properties.Item("CustomTool").Value = "PublicResXFileCodeGenerator"; } // We always want to build the RIA Services Projects because we need a couple of things to happen: // 1. CodeGen needs to occur to make the generated classes available in the client project, allowing it to compile // 2. We need the client project to be built so that its controls can be referenced in XAML // Without the build occurring here, VB solutions immediately showed build errors in the error list, and C# // solutions would show errors as soon as any of the XAML files were opened. // We build the silverlight project, which also causes VS to build the Web project because it is a dependency, // instead of the whole solution. That way, if there are additional projects in the solution, as is the case // with the Azure BAT template, those projects won't get built because of the RIA projects. var sb = this._solution2.SolutionBuild; if (silverlightProject != null) { sb.BuildProject(sb.ActiveConfiguration.Name, silverlightProject.UniqueName, /*WaitForBuildToFInish*/ true); } ProjectItem mainPage = this._solution2.FindProjectItem("MainPage.xaml"); System.Diagnostics.Debug.Assert(mainPage != null, "MainPage.xaml should always exist in the Silverlight project."); mainPage.Open(EnvDTE.Constants.vsViewKindPrimary); }
public void RunFinished() { Solution2 solution2 = (Solution2)this._dte2.Solution; string slClassLibProjectPath = this._slClassLibProject.FullName; string classLibName = this._replacementsDictionary["$safeprojectname$"]; // Determine whether the SL project was created in a Solution Folder. // If the user explicitly asked to Add Project under a Solution Folder, // it will be non-null. However if they ask to Create New Project under // a Solution Folder but change their mind to say "Add to Solution", // they will end up with the Silverlight project as a child of the SLN. ProjectItem projectItem = this._slClassLibProject.ParentProjectItem; ProjectItems projectItems = projectItem == null ? null : projectItem.Collection; Project parentProject = projectItems == null ? null : projectItems.Parent as Project; SolutionFolder slProjectParentSolutionFolder = (parentProject != null && parentProject.Kind == ProjectKinds.vsProjectKindSolutionFolder) ? parentProject.Object as SolutionFolder : null; // If the SL project was created in a Solution Folder, it wins because we cannot move it (see below). // However if the SL project was created as a child of the Solution, we have a choice. If a Solution Folder // was active when the user added the template, that is the one we will use. But if there was no active // Solution Folder, then we unconditionally create a new Solution Folder as a child of the Solution. SolutionFolder libFolder = slProjectParentSolutionFolder ?? this._activeSolutionFolder; if (libFolder == null) { try { // SL project was created directly under the Solution. Create a Solution Folder // to hold the pair of projects. libFolder = (SolutionFolder)((Project)solution2.AddSolutionFolder(classLibName)).Object; } catch (COMException) { libFolder = null; } } bool isVb = this._slClassLibProject.CodeModel.Language.Equals(CodeModelLanguageConstants.vsCMLanguageVB, StringComparison.OrdinalIgnoreCase); string language = isVb ? "VisualBasic" : "CSharp"; // CSDMain 228876 // Appending the FrameworkVersion to the file name when calling GetProjectTemplate is an undocumented way to request a specific $targetframeworkversion$ token // to become available to the child template. Without doing this, the default target framework value is used, which for VS 11 is 4.5. // Reference: http://www.visualstudiodev.com/visual-studio-extensibility/using-automation-to-create-templates-using-different-framework-versions-in-vs2008-23148.shtml string templateName = "ClassLibrary.zip|FrameworkVersion=" + this._replacementsDictionary["$targetframeworkversion$"]; string netClassLibProjectTemplate = solution2.GetProjectTemplate(templateName, language); string netClassLibProjectName = classLibName + ".Web"; string destination = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(slClassLibProjectPath)), netClassLibProjectName); // This code executes if we either created our own SolutionFolder or are using // the one the user chose. if (libFolder != null) { // Create the .NET class library in whichever SolutionFolder we decided to use above libFolder.AddFromTemplate(netClassLibProjectTemplate, destination, netClassLibProjectName); // If the SL project was created as a child of the Solution, we need to move it // into our new Solution Folder. However, if it was created in a Solution Folder, // we leave it as is. Dev10 bug 893488 disallows moving the SL project from one // Solution Folder to another, so this strategy avoids that issue. if (slProjectParentSolutionFolder == null) { // Move the Silverlight library under the folder solution2.Remove(this._slClassLibProject); this._slClassLibProject = libFolder.AddFromFile(slClassLibProjectPath); } } else { solution2.AddFromTemplate(netClassLibProjectTemplate, destination, netClassLibProjectName, false); } // Link the two class libraries together string extension = Path.GetExtension(slClassLibProjectPath); IVsSolution ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); IVsHierarchy hierarchy; ivsSolution.GetProjectOfUniqueName(_slClassLibProject.UniqueName, out hierarchy); IVsBuildPropertyStorage buildPropertyStorage = (IVsBuildPropertyStorage)hierarchy; buildPropertyStorage.SetPropertyValue("LinkedOpenRiaServerProject", null, (uint)_PersistStorageType.PST_PROJECT_FILE, Path.Combine("..", Path.Combine(netClassLibProjectName, netClassLibProjectName + extension))); buildPropertyStorage.SetPropertyValue("DisableFastUpToDateCheck", null, (uint)_PersistStorageType.PST_PROJECT_FILE, "true"); }
private void CommitCommandLineText(string CommandLine) { IVsHierarchy ProjectHierarchy; if (UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null) { Project SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy); if (SelectedStartupProject != null) { Configuration SelectedConfiguration = SelectedStartupProject.ConfigurationManager.ActiveConfiguration; if (SelectedConfiguration != null) { IVsBuildPropertyStorage PropertyStorage = ProjectHierarchy as IVsBuildPropertyStorage; if (PropertyStorage != null) { string FullCommandLine = CommandLine; // for "Game" projects automatically remove the game project filename from the start of the command line var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration; if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name)) { string AutoPrefix = Utils.GetAutoUProjectCommandLinePrefix(SelectedStartupProject); if (FullCommandLine.IndexOf(Utils.UProjectExtension, StringComparison.OrdinalIgnoreCase) < 0 && string.Compare(FullCommandLine, SelectedStartupProject.Name, StringComparison.OrdinalIgnoreCase) != 0 && !FullCommandLine.StartsWith(SelectedStartupProject.Name + " ", StringComparison.OrdinalIgnoreCase)) { // Committed command line does not specify a .uproject FullCommandLine = AutoPrefix + " " + FullCommandLine; } } // Get the project platform name. string ProjectPlatformName = SelectedConfiguration.PlatformName; if (ProjectPlatformName == "Any CPU") { ProjectPlatformName = "AnyCPU"; } // Get the project kind. C++ projects store the debugger arguments differently to other project types. string ProjectKind = SelectedStartupProject.Kind; // Update the property string ProjectConfigurationName = String.Format("{0}|{1}", SelectedConfiguration.ConfigurationName, ProjectPlatformName); if (String.Equals(ProjectKind, "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}", StringComparison.InvariantCultureIgnoreCase)) { List <string> ExtraFields = Utils.GetExtraDebuggerCommandArguments(ProjectPlatformName, SelectedStartupProject); if (FullCommandLine.Length == 0) { PropertyStorage.RemoveProperty("LocalDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE); PropertyStorage.RemoveProperty("RemoteDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE); foreach (string ExtraField in ExtraFields) { PropertyStorage.RemoveProperty(ExtraField, ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE); } } else { PropertyStorage.SetPropertyValue("LocalDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine); PropertyStorage.SetPropertyValue("RemoteDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine); foreach (string ExtraField in ExtraFields) { PropertyStorage.SetPropertyValue(ExtraField, ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine); } } } else { // For some reason, have to update C# projects this way, otherwise the properties page doesn't update. Conversely, SelectedConfiguration.Properties is always null for C++ projects in VS2017. if (SelectedConfiguration.Properties != null) { foreach (Property Property in SelectedConfiguration.Properties) { if (Property.Name.Equals("StartArguments", StringComparison.InvariantCultureIgnoreCase)) { Property.Value = FullCommandLine; break; } } } } } } } } CommitCommandLineToMRU(CommandLine); }