public override bool ChangeImport(string oldImportValue, string newImportValue) { XAttribute[] array = ( from import in this.ProjectImportAttributes where import.Value == oldImportValue select import).ToArray <XAttribute>(); if ((int)array.Length == 0) { return(false); } XAttribute[] xAttributeArray = array; for (int i = 0; i < (int)xAttributeArray.Length; i++) { XAttribute xAttribute = xAttributeArray[i]; string path = base.DocumentReference.Path; string updateImportAction = StringTable.UpdateImportAction; object[] value = new object[] { xAttribute.Value, newImportValue }; ProjectLog.LogSuccess(path, updateImportAction, value); xAttribute.Value = newImportValue; } return(true); }
public override IProjectItemData AddItem(string itemType, string itemValue) { Microsoft.Build.Evaluation.ProjectItem projectItem = this.AddMsBuildItem(itemType, itemValue); if (projectItem == null) { string path = base.DocumentReference.Path; string unknownError = StringTable.UnknownError; string addProjectItemAction = StringTable.AddProjectItemAction; object[] objArray = new object[] { itemType, itemValue }; ProjectLog.LogError(path, unknownError, addProjectItemAction, objArray); } else { string str = base.DocumentReference.Path; string addProjectItemAction1 = StringTable.AddProjectItemAction; object[] objArray1 = new object[] { itemType, itemValue }; ProjectLog.LogSuccess(str, addProjectItemAction1, objArray1); } if (projectItem == null) { return(null); } return(new MSBuildProjectItemData(projectItem)); }
protected override bool SetProperty(string name, string value, bool persisted) { string str; string unevaluatedValue; if (!persisted) { return(this.MsBuildProject.SetGlobalProperty(name, value)); } ProjectProperty property = this.MsBuildProject.GetProperty(name); if (!this.IsPropertyWritable(property)) { return(false); } if (value == null) { if (property == null) { return(true); } if (property.IsImported) { return(false); } bool flag = this.MsBuildProject.RemoveProperty(property); if (!flag) { string path = base.DocumentReference.Path; string unknownError = StringTable.UnknownError; string removePropertyAction = StringTable.RemovePropertyAction; object[] objArray = new object[] { name }; ProjectLog.LogError(path, unknownError, removePropertyAction, objArray); } else { ProjectLog.LogSuccess(base.DocumentReference.Path, StringTable.RemovePropertyAction, new object[] { name }); } return(flag); } if (property != null) { unevaluatedValue = property.UnevaluatedValue; } else { unevaluatedValue = null; } string str1 = unevaluatedValue; ProjectProperty projectProperty = this.MsBuildProject.SetProperty(name, value); if (!string.Equals(str1, value)) { if (string.IsNullOrEmpty(str1)) { CultureInfo currentCulture = CultureInfo.CurrentCulture; string setPropertyAction = StringTable.SetPropertyAction; object[] objArray1 = new object[] { name, value }; str = string.Format(currentCulture, setPropertyAction, objArray1); } else { CultureInfo cultureInfo = CultureInfo.CurrentCulture; string updatePropertyAction = StringTable.UpdatePropertyAction; object[] objArray2 = new object[] { name, str1, value }; str = string.Format(cultureInfo, updatePropertyAction, objArray2); } if (projectProperty == null) { ProjectLog.LogError(base.DocumentReference.Path, StringTable.UnknownError, str, new object[0]); } else { ProjectLog.LogSuccess(base.DocumentReference.Path, str, new object[0]); } } return(projectProperty != null); }
internal static void RepairAssemblyReferences(IProjectStore projectStore) { MSBuildBasedProjectStore mSBuildBasedProjectStore = projectStore as MSBuildBasedProjectStore; if (mSBuildBasedProjectStore == null) { return; } ProjectBuildContext projectBuildContext = mSBuildBasedProjectStore.GenerateNewBuildContext(null); AssemblyReferenceHelper.RebuildAssemblyReferencePaths(projectBuildContext); foreach (ItemResolutionPair itemResolutionPair in from assemblyPath in AssemblyReferenceHelper.GetAssemblyPaths(projectStore, projectBuildContext) where assemblyPath.ResolvedItem == null select assemblyPath) { string value = itemResolutionPair.SourceItem.Value; if (string.IsNullOrEmpty(value)) { continue; } int num = value.IndexOf(','); string fileNameWithoutExtension = null; if (num <= 0) { try { fileNameWithoutExtension = Path.GetFileNameWithoutExtension(value); } catch (IOException oException) { continue; } catch (ArgumentException argumentException) { continue; } if (string.Equals(fileNameWithoutExtension, value, StringComparison.OrdinalIgnoreCase)) { continue; } } else { fileNameWithoutExtension = value.Substring(0, num); } itemResolutionPair.SourceItem.Value = fileNameWithoutExtension; itemResolutionPair.SourceItem.SetItemMetadata("UpgraderOriginalValue", value); } projectBuildContext = mSBuildBasedProjectStore.GenerateNewBuildContext(null); AssemblyReferenceHelper.RebuildAssemblyReferencePaths(projectBuildContext); foreach (ItemResolutionPair itemResolutionPair1 in AssemblyReferenceHelper.GetAssemblyPaths(projectStore, projectBuildContext)) { string metadata = itemResolutionPair1.SourceItem.GetMetadata("UpgraderOriginalValue"); if (string.IsNullOrEmpty(metadata)) { continue; } if (itemResolutionPair1.ResolvedItem != null) { string path = projectStore.DocumentReference.Path; string updateItemMetadataAction = StringTable.UpdateItemMetadataAction; object[] itemType = new object[] { "Include", itemResolutionPair1.SourceItem.ItemType, metadata, metadata, itemResolutionPair1.SourceItem.Value }; ProjectLog.LogSuccess(path, updateItemMetadataAction, itemType); string metadataValue = itemResolutionPair1.ResolvedItem.GetMetadataValue("RequiredTargetFramework"); if (!string.IsNullOrEmpty(metadataValue)) { itemResolutionPair1.SourceItem.SetItemMetadata("RequiredTargetFramework", metadataValue); } } else { itemResolutionPair1.SourceItem.Value = metadata; } itemResolutionPair1.SourceItem.SetItemMetadata("UpgraderOriginalValue", null); } }
internal static void UpdateSourceControl(IEnumerable <DocumentReference> paths, UpdateSourceControlActions updateSourceControlAction, IProjectActionContext context) { if (context == null) { return; } IProjectManager projectManager = context.ServiceProvider.ProjectManager(); if (projectManager == null) { return; } ISolution currentSolution = projectManager.CurrentSolution; if (currentSolution == null || !currentSolution.IsSourceControlActive) { return; } SourceControlStatusCache.UpdateStatus(paths, context.ServiceProvider.SourceControlProvider()); IEnumerable <DocumentReference> documentReferences = paths.Where <DocumentReference>((DocumentReference path) => { if (!context.IsSourceControlled(path)) { return(false); } return(PathHelper.FileExists(path.Path)); }); IEnumerable <DocumentReference> documentReferences1 = Enumerable.Empty <DocumentReference>(); if ((updateSourceControlAction & UpdateSourceControlActions.Checkout) == UpdateSourceControlActions.Checkout) { IEnumerable <DocumentReference> cachedStatus = from path in documentReferences where SourceControlStatusCache.GetCachedStatus(path) == SourceControlStatus.CheckedIn select path; if (context.ServiceProvider.SourceControlProvider().Checkout(( from path in cachedStatus select path.Path).ToArray <string>()) != SourceControlSuccess.Success) { documentReferences1.Concat <DocumentReference>(cachedStatus); } else { SourceControlStatusCache.SetCachedStatus(cachedStatus, SourceControlStatus.CheckedOut); foreach (DocumentReference cachedStatu in cachedStatus) { ProjectLog.LogSuccess(cachedStatu.Path, StringTable.MakeWritableAction, new object[0]); } } } if ((updateSourceControlAction & UpdateSourceControlActions.PendAdd) == UpdateSourceControlActions.PendAdd) { IEnumerable <DocumentReference> cachedStatus1 = from path in documentReferences where SourceControlStatusCache.GetCachedStatus(path) == SourceControlStatus.None select path; if (context.ServiceProvider.SourceControlProvider().Add(( from path in cachedStatus1 select path.Path).ToArray <string>()) != SourceControlSuccess.Success) { documentReferences1.Concat <DocumentReference>(cachedStatus1); } else { SourceControlStatusCache.SetCachedStatus(cachedStatus1, SourceControlStatus.Add); } } SourceControlStatusCache.UpdateStatus(documentReferences1, context.ServiceProvider.SourceControlProvider()); }