Browse Source

Use dotnet publish to make static assets work (#148)

- This will prevent it from using relative paths for static assets
pull/152/head
David Fowler 6 years ago
committed by GitHub
parent
commit
2c34fd9b88
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/Microsoft.Tye.Hosting/TransformProjectsIntoContainers.cs

12
src/Microsoft.Tye.Hosting/TransformProjectsIntoContainers.cs

@ -46,27 +46,27 @@ namespace Microsoft.Tye.Hosting
service.Status.ProjectFilePath = fullProjectPath;
// Sometimes building can fail because of file locking (like files being open in VS)
_logger.LogInformation("Building project {ProjectFile}", service.Status.ProjectFilePath);
_logger.LogInformation("Publishing project {ProjectFile}", service.Status.ProjectFilePath);
service.Logs.OnNext($"dotnet build \"{service.Status.ProjectFilePath}\" /nologo");
service.Logs.OnNext($"dotnet publish \"{service.Status.ProjectFilePath}\" /nologo");
var buildResult = await ProcessUtil.RunAsync("dotnet", $"build \"{service.Status.ProjectFilePath}\" /nologo",
var buildResult = await ProcessUtil.RunAsync("dotnet", $"publish \"{service.Status.ProjectFilePath}\" /nologo",
outputDataReceived: data => service.Logs.OnNext(data),
throwOnError: false);
if (buildResult.ExitCode != 0)
{
_logger.LogInformation("Building {ProjectFile} failed with exit code {ExitCode}: " + buildResult.StandardOutput + buildResult.StandardError, service.Status.ProjectFilePath, buildResult.ExitCode);
_logger.LogInformation("Publishing {ProjectFile} failed with exit code {ExitCode}: " + buildResult.StandardOutput + buildResult.StandardError, service.Status.ProjectFilePath, buildResult.ExitCode);
return;
}
var targetFramework = GetTargetFramework(service.Status.ProjectFilePath);
// We transform the project information into the following docker command:
// docker run -w /app -v {projectDir}:/app -it {image} dotnet /app/bin/Debug/{tfm}/{outputfile}.dll
// docker run -w /app -v {projectDir}:/app -it {image} dotnet /app/bin/Debug/{tfm}/publish/{outputfile}.dll
var containerImage = DetermineContainerImage(targetFramework);
var outputFileName = Path.GetFileNameWithoutExtension(service.Status.ProjectFilePath) + ".dll";
var dockerRunInfo = new DockerRunInfo(containerImage, $"dotnet /app/bin/Debug/{targetFramework}/{outputFileName} {project.Args}")
var dockerRunInfo = new DockerRunInfo(containerImage, $"dotnet /app/bin/Debug/{targetFramework}/publish/{outputFileName} {project.Args}")
{
WorkingDirectory = "/app"
};

Loading…
Cancel
Save