Browse Source

Fix dapr paths (#701)

* Fix Dapr paths

* oops
pull/703/head
Justin Kotalik 6 years ago
committed by GitHub
parent
commit
f1b145fbee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      src/Microsoft.Tye.Extensions/Dapr/DaprExtension.cs

29
src/Microsoft.Tye.Extensions/Dapr/DaprExtension.cs

@ -6,6 +6,7 @@ using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Microsoft.Tye.Extensions.Dapr
@ -42,7 +43,9 @@ namespace Microsoft.Tye.Extensions.Dapr
throw new CommandException("Dapr support does not support multiple replicas yet for development.");
}
var proxy = new ExecutableServiceBuilder($"{project.Name}-dapr", "daprd")
var daprExecutablePath = GetDaprExecutablePath();
var proxy = new ExecutableServiceBuilder($"{project.Name}-dapr", daprExecutablePath)
{
WorkingDirectory = context.Application.Source.DirectoryName,
@ -204,5 +207,29 @@ namespace Microsoft.Tye.Extensions.Dapr
return Task.CompletedTask;
}
private string GetDaprExecutablePath()
{
// Starting with dapr version 11, dapr is installed in user profile/home.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var windowsPath = Environment.ExpandEnvironmentVariables("%USERPROFILE%/.dapr/bin/daprd.exe");
if (File.Exists(windowsPath))
{
return windowsPath;
}
}
else
{
var nixpath = Environment.ExpandEnvironmentVariables("$HOME/.dapr/bin/daprd");
if (File.Exists(nixpath))
{
return nixpath;
}
}
// Older version of dapr don't have dapr in the bin directory, but it is usually on the path.
return "daprd";
}
}
}

Loading…
Cancel
Save