@@ -42,45 +42,12 @@ RUN msbuild src\LocalGovIms.sln `
4242
4343WORKDIR C:\h ash-password
4444
45+ # Copy hash-password source files (avoids PowerShell here-string issues in Docker)
46+ COPY hash-password/ C:\h ash-password\
47+
4548# Download the NuGet package for ASP.NET Identity
4649RUN nuget install Microsoft.AspNet.Identity.Core -Version 2.2.4 -OutputDirectory packages
4750
48- # Write the C# source
49- RUN Set-Content -Path Program.cs -Value @' `
50- using System; `
51- using Microsoft.AspNet.Identity; `
52- class Program { `
53- static void Main() { `
54- var password = Console.ReadLine(); `
55- var hasher = new PasswordHasher(); `
56- Console.Write(hasher.HashPassword(password)); `
57- } `
58- } `
59- ' @
60-
61- # Write the project file
62- RUN Set-Content -Path HashPassword.csproj -Value @' `
63- <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> `
64- <Import Project="$(MSBuildExtensionsPath)\$ (MSBuildToolsVersion)\M icrosoft.Common.props" /> `
65- <PropertyGroup> `
66- <OutputType>Exe</OutputType> `
67- <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> `
68- <OutputPath>bin\< /OutputPath> `
69- <AssemblyName>hash-password</AssemblyName> `
70- </PropertyGroup> `
71- <ItemGroup> `
72- <Reference Include="Microsoft.AspNet.Identity.Core"> `
73- <HintPath>packages\M icrosoft.AspNet.Identity.Core.2.2.4\l ib\n et45\M icrosoft.AspNet.Identity.Core.dll</HintPath> `
74- </Reference> `
75- <Reference Include="System" /> `
76- </ItemGroup> `
77- <ItemGroup> `
78- <Compile Include="Program.cs" /> `
79- </ItemGroup> `
80- <Import Project="$(MSBuildToolsPath)\M icrosoft.CSharp.targets" /> `
81- </Project> `
82- ' @
83-
8451RUN msbuild HashPassword.csproj /p:Configuration=Release /verbosity:minimal
8552
8653# Copy to tools directory
@@ -119,39 +86,8 @@ RUN dotnet restore ; `
11986
12087WORKDIR C:\e fmigrate
12188
122- # Write the project file referencing the GOV.UK Pay Infrastructure project
123- RUN Set-Content -Path efmigrate.csproj -Value @' `
124- <Project Sdk="Microsoft.NET.Sdk"> `
125- <PropertyGroup> `
126- <OutputType>Exe</OutputType> `
127- <TargetFramework>net6.0</TargetFramework> `
128- <ImplicitUsings>enable</ImplicitUsings> `
129- </PropertyGroup> `
130- <ItemGroup> `
131- <ProjectReference Include="..\s rc\I nfrastructure\I nfrastructure.csproj" /> `
132- </ItemGroup> `
133- </Project> `
134- ' @
135-
136- # Write the migration runner
137- RUN Set-Content -Path Program.cs -Value @' `
138- using Microsoft.EntityFrameworkCore; `
139- using Microsoft.Extensions.DependencyInjection; `
140- `
141- var connectionString = args.FirstOrDefault(a => a.StartsWith("--connection="))?.Substring("--connection=".Length) `
142- ?? throw new ArgumentException("Usage: efmigrate --connection=<connection-string>"); `
143- `
144- Console.WriteLine("Running EF Core migrations for GOV.UK Pay integration..."); `
145- `
146- // Build DbContext with the provided connection string `
147- var optionsBuilder = new DbContextOptionsBuilder<LocalGovIms.Integration.GovUKPay.Infrastructure.GovUkPayDbContext>(); `
148- optionsBuilder.UseSqlServer(connectionString); `
149- `
150- using var context = new LocalGovIms.Integration.GovUKPay.Infrastructure.GovUkPayDbContext(optionsBuilder.Options); `
151- context.Database.Migrate(); `
152- `
153- Console.WriteLine("EF Core migrations completed successfully."); `
154- ' @
89+ # Copy efmigrate source files (avoids PowerShell here-string issues in Docker)
90+ COPY efmigrate/ C:\e fmigrate\
15591
15692RUN dotnet publish efmigrate.csproj -c Release -o C:\e fmigrate-out
15793
0 commit comments