public override void Execute(ProjectBuildContext context) { context .GetFile("/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json") .ReplaceText("44395", "44361") .ReplaceText("44348", "44361"); }
private void ChangeNamespaceAndKeyword( ProjectBuildContext context, string targetModuleFilePath, string oldNamespace, string newNamespace, string oldKeyword, string newKeyword) { var file = context.GetFile(targetModuleFilePath); file.NormalizeLineEndings(); var lines = file.GetLines(); for (var i = 0; i < lines.Length; i++) { if (lines[i].Contains($"using {oldNamespace};")) { lines[i] = $"using {newNamespace};"; } else if (lines[i].Contains(oldKeyword)) { lines[i] = lines[i].Replace(oldKeyword, newKeyword); } } file.SetLines(lines); }
public override void Execute(ProjectBuildContext context) { context .GetFile("/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json") .ReplaceText("44300", RemoteServicePort) .ReplaceText("44301", IdentityServerPort); }
public override void Execute(ProjectBuildContext context) { new RemoveFolderStep(_projectFolderPath).Execute(context); var solutionFile = context.GetFile(_solutionFilePath); solutionFile.NormalizeLineEndings(); solutionFile.SetLines(RemoveProject(solutionFile.GetLines().ToList())); }
public override void Execute(ProjectBuildContext context) { context.Files.RemoveAll(file => file.Name.StartsWith(_projectFolderPath)); var solutionFile = context.GetFile(_solutionFilePath); solutionFile.NormalizeLineEndings(); solutionFile.SetLines(RemoveProject(solutionFile.GetLines().ToList())); }
public override void Execute(ProjectBuildContext context) { context .GetFile("/aspnet-core/MyCompanyName.MyProjectName.sln") .ReplaceText(_oldProjectName, _newProjectName); RenameHelper.RenameAll(context.Files, _oldProjectName, _newProjectName); }
public override void Execute(ProjectBuildContext context) { SetSolutionAndProjectPathsIfNull(context); if (_solutionFilePath == null || _projectFolderPath == null) { return; } new RemoveFolderStep(_projectFolderPath).Execute(context); var solutionFile = context.GetFile(_solutionFilePath); solutionFile.NormalizeLineEndings(); solutionFile.SetLines(RemoveProject(solutionFile.GetLines().ToList())); }
public override void Execute(ProjectBuildContext context) { var launchSettings = context.GetFile(LaunchSettingsFilePath); var randomPort = RandomHelper.GetRandom(50001, 59990); var newContent = launchSettings.Content; for (var i = 0; i < PortNumbers.Length; i++) { newContent = newContent.Replace( PortNumbers[i].ToString(), (randomPort + i).ToString() ); } launchSettings.SetContent(newContent); }
private static void RemoveKeyword(ProjectBuildContext context, string targetModuleFilePath, string keyword) { var file = context.GetFile(targetModuleFilePath); file.NormalizeLineEndings(); var lines = file.GetLines(); var newLines = new List <string>(); for (var i = 0; i < lines.Length; i++) { if (!lines[i].Contains(keyword)) { newLines.Add(lines[i]); } } file.SetLines(newLines); }
private void ChangeConnectionString(ProjectBuildContext context) { var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/appsettings.json"); file.NormalizeLineEndings(); var lines = file.GetLines(); for (var i = 0; i < lines.Length; i++) { if (lines[i].Contains("Default") && lines[i].Contains("Database")) { lines[i] = " \"Default\": \"mongodb://localhost:27017|MyProjectName\""; file.SetLines(lines); return; } } throw new ApplicationException("Could not find the 'Default' connection string in appsettings.json file!"); }
private void ChangeProjectReference(ProjectBuildContext context) { var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj"); file.NormalizeLineEndings(); var lines = file.GetLines(); for (var i = 0; i < lines.Length; i++) { if (lines[i].Contains("ProjectReference") && lines[i].Contains("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")) { lines[i] = lines[i].Replace("EntityFrameworkCore.DbMigrations", "MongoDB"); file.SetLines(lines); return; } } throw new ApplicationException("Could not find the EntityFrameworkCore reference in the MyCompanyName.MyProjectName.Web.csproj!"); }
private void ChangeProjectReference( ProjectBuildContext context, string targetProjectFilePath, string oldReference, string newReference) { var file = context.GetFile(targetProjectFilePath); file.NormalizeLineEndings(); var lines = file.GetLines(); for (var i = 0; i < lines.Length; i++) { if (lines[i].Contains("ProjectReference") && lines[i].Contains(oldReference)) { lines[i] = lines[i].Replace(oldReference, newReference); file.SetLines(lines); return; } } throw new ApplicationException($"Could not find the '{oldReference}' reference in the project '{targetProjectFilePath}'!"); }
private void ChangeWebModuleUsage(ProjectBuildContext context) { var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs"); file.NormalizeLineEndings(); file.RemoveTemplateCodeIfNot("EntityFrameworkCore"); var lines = file.GetLines(); for (var i = 0; i < lines.Length; i++) { if (lines[i].Contains("using MyCompanyName.MyProjectName.EntityFrameworkCore")) { lines[i] = "using MyCompanyName.MyProjectName.MongoDb;"; } else if (lines[i].Contains("MyProjectNameEntityFrameworkCoreModule")) { lines[i] = lines[i].Replace("MyProjectNameEntityFrameworkCoreModule", "MyProjectNameMongoDbModule"); } } file.SetLines(lines); }
public override void Execute(ProjectBuildContext context) { context .GetFile("/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json") .ReplaceText("44305", AuthServerPort); }