You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
1.2 KiB

  1. param (
  2. [string]$solution = "eShopOnContainers-ServicesAndWebApps.sln"
  3. )
  4. $outfile = "DockerfileSolutionRestore.txt"
  5. # This script creates the $outfile file, with Dockerfile commands to restore all the packages for the solution,
  6. # so you can insert them (by hand) into Dockerfiles right before the "COPY . ." line
  7. # to increase build speed by optimizing the use of docker build images cache.
  8. # This script is only needed when adding or removing projects from the solution.
  9. Write-Output "COPY ""$solution"" ""$solution""" > $outfile
  10. Add-Content -Path $outfile ""
  11. Select-String -Path $solution -Pattern ', "(.*?\.csproj)"' | ForEach-Object { $_.Matches.Groups[1].Value.Replace("\", "/") } | Sort-Object | ForEach-Object {"COPY ""$_"" ""$_"""} | Out-File -FilePath $outfile -Append
  12. Add-Content -Path $outfile ""
  13. Select-String -Path $solution -Pattern ', "(.*?\.dcproj)"' | ForEach-Object { $_.Matches.Groups[1].Value.Replace("\", "/") } | Sort-Object | ForEach-Object {"COPY ""$_"" ""$_"""} | Out-File -FilePath $outfile -Append
  14. Add-Content -Path $outfile ""
  15. Add-Content -Path $outfile "COPY ""NuGet.config"" ""NuGet.config"""
  16. Add-Content -Path $outfile ""
  17. Add-Content -Path $outfile "RUN dotnet restore ""$solution"""
  18. Get-Content $outfile