コード例 #1
0
 public override void Execute(ProjectBuildContext context)
 {
     context
     .GetFile("/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json")
     .ReplaceText("44395", "44361")
     .ReplaceText("44348", "44361");
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 public override void Execute(ProjectBuildContext context)
 {
     context
     .GetFile("/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json")
     .ReplaceText("44300", RemoteServicePort)
     .ReplaceText("44301", IdentityServerPort);
 }
コード例 #4
0
 public override void Execute(ProjectBuildContext context)
 {
     new RemoveFolderStep(_projectFolderPath).Execute(context);
     var solutionFile = context.GetFile(_solutionFilePath);
     solutionFile.NormalizeLineEndings();
     solutionFile.SetLines(RemoveProject(solutionFile.GetLines().ToList()));
 }
コード例 #5
0
        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()));
        }
コード例 #6
0
        public override void Execute(ProjectBuildContext context)
        {
            context
            .GetFile("/aspnet-core/MyCompanyName.MyProjectName.sln")
            .ReplaceText(_oldProjectName, _newProjectName);

            RenameHelper.RenameAll(context.Files, _oldProjectName, _newProjectName);
        }
コード例 #7
0
        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()));
        }
コード例 #8
0
        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);
        }
コード例 #9
0
    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);
    }
コード例 #10
0
        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!");
        }
コード例 #11
0
        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!");
        }
コード例 #12
0
        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}'!");
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public override void Execute(ProjectBuildContext context)
 {
     context
     .GetFile("/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json")
     .ReplaceText("44305", AuthServerPort);
 }