public static void SetVSProjectPropertie(this ICakeContext context, FilePath projectFilePath, string key, string value, string configure = "Release", string platform = "AnyCPU") { if (context == null) { throw new ArgumentNullException("context"); } if (projectFilePath == null) { throw new ArgumentNullException("projectFilePath"); } if (projectFilePath.IsRelative) { projectFilePath = projectFilePath.MakeAbsolute(context.Environment); } var file = context.FileSystem.GetFile(projectFilePath); if (!file.Exists) { const string format = "Project file '{0}' does not exist."; var message = string.Format(CultureInfo.InvariantCulture, format, projectFilePath.FullPath); throw new CakeException(message); } configure = configure.ToLower(); platform = platform.ToLower(); ProjectFileHelper helper = new ProjectFileHelper(file.Path.FullPath); helper.SetProperty(key, value, configure, platform); helper.Save(); }
public static IDictionary <string, string> GetVSProjectProperties(this ICakeContext context, FilePath projectFilePath, IEnumerable <string> keys, string configure = "Release", string platform = "AnyCPU") { if (context == null) { throw new ArgumentNullException("context"); } if (projectFilePath == null) { throw new ArgumentNullException("projectFilePath"); } if (projectFilePath.IsRelative) { projectFilePath = projectFilePath.MakeAbsolute(context.Environment); } var file = context.FileSystem.GetFile(projectFilePath); if (!file.Exists) { const string format = "Project file '{0}' does not exist."; var message = string.Format(CultureInfo.InvariantCulture, format, projectFilePath.FullPath); throw new CakeException(message); } Dictionary <string, string> keyValues = new Dictionary <string, string>(); configure = configure.ToLower(); platform = platform.ToLower(); ProjectFileHelper helper = new ProjectFileHelper(file.Path.FullPath); foreach (var key in keys) { string value = helper.GetProperty(key, configure, platform); if (!string.IsNullOrEmpty(value)) { keyValues.Add(key, value); } } return(keyValues); }