Browse Source

Fixed updating properties in .user file.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3754 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
e8edfd0864
  1. 51
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  2. 1
      src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDescriptor.cs

51
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -9,14 +9,14 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.IO; using System.IO;
using System.Linq;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Internal.Templates;
using MSBuild = Microsoft.Build.BuildEngine; using MSBuild = Microsoft.Build.BuildEngine;
using StringPair = ICSharpCode.SharpDevelop.Pair<System.String, System.String>; using StringPair = ICSharpCode.SharpDevelop.Pair<string, string>;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
{ {
@ -616,7 +616,7 @@ namespace ICSharpCode.SharpDevelop.Project
// Recreate the property using the saved value // Recreate the property using the saved value
foreach (KeyValuePair<string, string> pair in oldValuesConf) { foreach (KeyValuePair<string, string> pair in oldValuesConf) {
if (pair.Value != null) { if (pair.Value != null) {
targetProject.SetProperty(propertyName, pair.Value, MSBuildSetProperty(targetProject, propertyName, pair.Value,
CreateCondition(pair.Key, null, location), CreateCondition(pair.Key, null, location),
propertyInsertionPosition, propertyInsertionPosition,
false); false);
@ -636,7 +636,7 @@ namespace ICSharpCode.SharpDevelop.Project
// Recreate the property using the saved value // Recreate the property using the saved value
foreach (KeyValuePair<string, string> pair in oldValuesPlat) { foreach (KeyValuePair<string, string> pair in oldValuesPlat) {
if (pair.Value != null) { if (pair.Value != null) {
targetProject.SetProperty(propertyName, pair.Value, MSBuildSetProperty(targetProject, propertyName, pair.Value,
CreateCondition(null, pair.Key, location), CreateCondition(null, pair.Key, location),
propertyInsertionPosition, propertyInsertionPosition,
false); false);
@ -658,7 +658,7 @@ namespace ICSharpCode.SharpDevelop.Project
// Recreate the property using the saved value // Recreate the property using the saved value
foreach (KeyValuePair<StringPair, string> pair in oldValues) { foreach (KeyValuePair<StringPair, string> pair in oldValues) {
if (pair.Value != null) { if (pair.Value != null) {
targetProject.SetProperty(propertyName, pair.Value, MSBuildSetProperty(targetProject, propertyName, pair.Value,
CreateCondition(pair.Key.First, pair.Key.Second, location), CreateCondition(pair.Key.First, pair.Key.Second, location),
propertyInsertionPosition, propertyInsertionPosition,
false); false);
@ -687,23 +687,24 @@ namespace ICSharpCode.SharpDevelop.Project
args.NewValue = treatPropertyValueAsLiteral ? MSBuildInternals.Escape(newValue) : newValue; args.NewValue = treatPropertyValueAsLiteral ? MSBuildInternals.Escape(newValue) : newValue;
} }
if (newValue == null) {
if (existingPropertyGroup != null && existingProperty != null) { if (existingPropertyGroup != null && existingProperty != null) {
// update or delete existing property
args.OldValue = existingProperty.Value; args.OldValue = existingProperty.Value;
MSBuildSetProperty(targetProject, propertyName, newValue ?? "",
existingPropertyGroup.Condition,
propertyInsertionPosition,
treatPropertyValueAsLiteral);
if (newValue == null) {
// delete existing property
existingPropertyGroup.RemoveProperty(existingProperty); existingPropertyGroup.RemoveProperty(existingProperty);
if (existingPropertyGroup.Count == 0) { if (existingPropertyGroup.Count == 0) {
targetProject.RemovePropertyGroup(existingPropertyGroup); targetProject.RemovePropertyGroup(existingPropertyGroup);
} }
} }
} else if (existingPropertyGroup != null && existingProperty != null) { } else if (newValue != null) {
args.OldValue = existingProperty.Value; // create new property
targetProject.SetProperty(propertyName, newValue, MSBuildSetProperty(targetProject, propertyName, newValue,
existingPropertyGroup.Condition,
propertyInsertionPosition,
treatPropertyValueAsLiteral);
} else {
targetProject.SetProperty(propertyName, newValue,
CreateCondition(configuration, platform, location), CreateCondition(configuration, platform, location),
propertyInsertionPosition, propertyInsertionPosition,
treatPropertyValueAsLiteral); treatPropertyValueAsLiteral);
@ -711,6 +712,19 @@ namespace ICSharpCode.SharpDevelop.Project
return args; return args;
} }
void MSBuildSetProperty(MSBuild.Project targetProject, string propertyName, string newValue,
string groupCondition, MSBuild.PropertyPosition position,
bool treatPropertyValueAsLiteral)
{
if (targetProject == project) {
project.SetProperty(propertyName, newValue, groupCondition, position, treatPropertyValueAsLiteral);
} else if (targetProject == userProject) {
project.SetImportedProperty(propertyName, newValue, groupCondition, userProject, position, treatPropertyValueAsLiteral);
} else {
throw new ArgumentException();
}
}
/// <summary> /// <summary>
/// Removes the property from all configurations and platforms. /// Removes the property from all configurations and platforms.
/// </summary> /// </summary>
@ -1051,13 +1065,6 @@ namespace ICSharpCode.SharpDevelop.Project
if (base.IdGuid == null) { if (base.IdGuid == null) {
// Save the GUID in the project if the project does not yet have a GUID. // Save the GUID in the project if the project does not yet have a GUID.
SetPropertyInternal(null, null, ProjectGuidPropertyName, value, PropertyStorageLocations.Base, true); SetPropertyInternal(null, null, ProjectGuidPropertyName, value, PropertyStorageLocations.Base, true);
try {
// save fixed project
project.Save(this.FileName);
} catch (IOException) {
} catch (AccessViolationException) {
// Ignore errors writing the fixed project file
}
} }
base.IdGuid = value; base.IdGuid = value;
} }

1
src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDescriptor.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.SharpDevelop
} }
} }
public string Guid { public string Guid {
get { get {
return codon.Properties["guid"]; return codon.Properties["guid"];

Loading…
Cancel
Save