Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Error when exporting developer certificate from Windows machine has a username contains space #635

Closed
taqabubaker opened this issue Aug 21, 2020 · 3 comments · Fixed by #647
Labels
bug Something isn't working

Comments

@taqabubaker
Copy link
Contributor

Describe the bug

Tye fails to export the developer certificate from the Windows machine when the current logged in user's username contains space. This happens because the certificateDirectory.DirectoryPath which is generated using the TempDirectory.Create is within the temp directory. Windows Temp directory format is like C:\Users\UserName\AppData\Local\Temp so in case the UserName contains space (e.g. Tariq Abubaker) the temp directory will be C:\Users\Tariq Abubaker\AppData\Local\Temp\. This will fail exporting the certificate dotnet dev-certs command when the ProcessUtil.RunAsync run it because of the breaking space e.g. dotnet dev-certs https -ep C:\Users\Tariq Abubaker\AppData\Local\Temp\3jx13zqv.zfg\frontend.pfx -p 26739b5b-e7c5-44bc-8f04-e989dea7a936.

Tye-exportCertificateIssue

To Reproduce

What steps can we follow to reproduce the issue?

  1. Use a Windows machine with username contains a space e.g. Tariq Abubaker
  2. Run any project you have with --docker option i.e. tye run --docker

Got Exceptions? Include both the message and the stack trace

tye run --docker
Loading Application Details...
Launching Tye Host...

[21:04:48 INF] Executing application from D:\Tariq's Projects\microservice\tye.yaml
[21:04:49 INF] dtrace: Using Zipkin at URL http://localhost:9411
[21:04:49 INF] logs: Using ElasticSearch at http://localhost:9200
[21:04:49 INF] Dashboard running on http://127.0.0.1:8000
[21:04:49 INF] Publishing project D:\Tariq's Projects\microservice\frontend\frontend.csproj
[21:04:49 INF] Publishing project D:\Tariq's Projects\microservice\backend\backend.csproj
An unhandled exception has occurred, how unseemly:
System.InvalidOperationException: Command dotnet dev-certs https -ep C:\Users\Tariq Abubaker\AppData\Local\Temp\3jx13zqv.zfg\frontend.pfx -p 26739b5b-e7c5-44bc-8f04-e989dea7a936 returned exit code -1
   at Microsoft.Tye.ProcessUtil.RunAsync(String filename, String arguments, String workingDirectory, Boolean throwOnError, IDictionary`2 environmentVariables, Action`1 outputDataReceived, Action`1 errorDataReceived, Action`1 onStart, Action`1 onStop, CancellationToken cancellationToken) in /_/src/Microsoft.Tye.Core/ProcessUtil.cs:line 140
   at Microsoft.Tye.ProcessUtil.RunAsync(String filename, String arguments, String workingDirectory, Boolean throwOnError, IDictionary`2 environmentVariables, Action`1 outputDataReceived, Action`1 errorDataReceived, Action`1 onStart, Action`1 onStop, CancellationToken cancellationToken)
   at Microsoft.Tye.Hosting.TransformProjectsIntoContainers.TransformProjectToContainer(Service service, ProjectRunInfo project) in /_/src/Microsoft.Tye.Hosting/TransformProjectsIntoContainers.cs:line 116
   at Microsoft.Tye.Hosting.AggregateApplicationProcessor.StartAsync(Application application) in /_/src/Microsoft.Tye.Hosting/AggregateApplicationProcessor.cs:line 24
   at Microsoft.Tye.Hosting.TyeHost.StartAsync() in /_/src/Microsoft.Tye.Hosting/TyeHost.cs:line 96
   at Microsoft.Tye.Hosting.TyeHost.RunAsync() in /_/src/Microsoft.Tye.Hosting/TyeHost.cs:line 60
   at Microsoft.Tye.Hosting.TyeHost.RunAsync() in /_/src/Microsoft.Tye.Hosting/TyeHost.cs:line 70
   at Microsoft.Tye.Program.<>c.<<CreateRunCommand>b__10_0>d.MoveNext() in /_/src/tye/Program.RunCommand.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Tye.Program.<>c.<<CreateRunCommand>b__10_0>d.MoveNext() in /_/src/tye/Program.RunCommand.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__19_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__10_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseExceptionHandler>b__0>d.MoveNext()

Further technical details

  • Include the output of tye --version
    0.4.0-alpha.20371.1+d7623120d66b85bfeda8ab69eb5ff792df6b7243

  • If possible rerun the command with -v debug and include the output

tye run --docker -v debug
Loading Application Details...
Locating .NET SDK...
Found .NET SDK at: C:\Program Files\dotnet\sdk\3.1.202\
Registered .NET SDK.Loading project 'D:\Tariq's Projects\microservice\frontend\frontend.csproj'.
Loaded project 'D:\Tariq's Projects\microservice\frontend\frontend.csproj'.
Restoring project 'D:\Tariq's Projects\microservice\frontend\frontend.csproj'.
Build started 21-Aug-20 9:32:02 PM.
__________________________________________________
Project "D:\Tariq's Projects\microservice\frontend\frontend.csproj" (Restore target(s)):

Target _FilterRestoreGraphProjectInputItems:
    __________________________________________________
    Project "D:\Tariq's Projects\microservice\frontend\frontend.csproj" is building "D:\Tariq's Projects\microservice\frontend\frontend.csproj" (_IsProjectRestoreSupported target(s)):

Target _GetAllRestoreProjectPathItems:
    __________________________________________________
    Project "D:\Tariq's Projects\microservice\frontend\frontend.csproj" is building "D:\Tariq's Projects\microservice\frontend\frontend.csproj" (_GenerateRestoreProjectPathWalk target(s)):

    __________________________________________________
    Project "D:\Tariq's Projects\microservice\frontend\frontend.csproj" is building "D:\Tariq's Projects\microservice\frontend\frontend.csproj" (_IsProjectRestoreSupported target(s)):

Target _GenerateRestoreGraph:
    __________________________________________________
    Project "D:\Tariq's Projects\microservice\frontend\frontend.csproj" is building "D:\Tariq's Projects\microservice\frontend\frontend.csproj" (_GenerateRestoreGraphProjectEntry target(s)):

    __________________________________________________
    Project "D:\Tariq's Projects\microservice\frontend\frontend.csproj" is building "D:\Tariq's Projects\microservice\frontend\frontend.csproj" (_GenerateProjectRestoreGraph target(s)):

Target Restore:
    Committing restore...
    Assets file has not changed. Skipping assets file writing. Path: D:\Tariq's Projects\microservice\frontend\obj\project.assets.json
    Restore completed in 84.25 ms for D:\Tariq's Projects\microservice\frontend\frontend.csproj.

    NuGet Config files used:
        C:\Users\Tariq Abubaker\AppData\Roaming\NuGet\NuGet.Config
        C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
        C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config

    Feeds used:
        https://api.nuget.org/v3/index.json
        https://nuget.devexpress.com/netconf2019/api
        C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.31
Restored project 'D:\Tariq's Projects\microservice\frontend\frontend.csproj'.
Build started 21-Aug-20 9:32:03 PM.
__________________________________________________
Project "D:\Tariq's Projects\microservice\frontend\frontend.csproj" (ResolveReferences;ResolvePackageDependenciesDesignTime;PrepareResources;GetAssemblyAttributes target(s)):


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.42
Found application version: 1.0.0
RunCommand=D:\Tariq's Projects\microservice\frontend\bin\Debug\netcoreapp3.1\frontend.exe
RunArguments=
TargetPath=D:\Tariq's Projects\microservice\frontend\bin\Debug\netcoreapp3.1\frontend.dll
PublishDir=bin\Debug\netcoreapp3.1\publish\
AssemblyName=frontend
IntermediateOutputPath=obj\Debug\netcoreapp3.1\
Found target framework: netcoreapp3.1
Found shared frameworks: Microsoft.NETCore.App, Microsoft.AspNetCore.App
IsAspNet=True
Evaluation Took: 2799.4723ms
Loading project 'D:\Tariq's Projects\microservice\backend\backend.csproj'.
Loaded project 'D:\Tariq's Projects\microservice\backend\backend.csproj'.
Restoring project 'D:\Tariq's Projects\microservice\backend\backend.csproj'.
Build started 21-Aug-20 9:32:04 PM.
__________________________________________________
Project "D:\Tariq's Projects\microservice\backend\backend.csproj" (Restore target(s)):

Target _FilterRestoreGraphProjectInputItems:
    __________________________________________________
    Project "D:\Tariq's Projects\microservice\backend\backend.csproj" is building "D:\Tariq's Projects\microservice\backend\backend.csproj" (_IsProjectRestoreSupported target(s)):

Target _GetAllRestoreProjectPathItems:
    __________________________________________________
    Project "D:\Tariq's Projects\microservice\backend\backend.csproj" is building "D:\Tariq's Projects\microservice\backend\backend.csproj" (_GenerateRestoreProjectPathWalk target(s)):

    __________________________________________________
    Project "D:\Tariq's Projects\microservice\backend\backend.csproj" is building "D:\Tariq's Projects\microservice\backend\backend.csproj" (_IsProjectRestoreSupported target(s)):

Target _GenerateRestoreGraph:
    __________________________________________________
    Project "D:\Tariq's Projects\microservice\backend\backend.csproj" is building "D:\Tariq's Projects\microservice\backend\backend.csproj" (_GenerateRestoreGraphProjectEntry target(s)):

    __________________________________________________
    Project "D:\Tariq's Projects\microservice\backend\backend.csproj" is building "D:\Tariq's Projects\microservice\backend\backend.csproj" (_GenerateProjectRestoreGraph target(s)):

Target Restore:
    Committing restore...
    Assets file has not changed. Skipping assets file writing. Path: D:\Tariq's Projects\microservice\backend\obj\project.assets.json    Restore completed in 12.43 ms for D:\Tariq's Projects\microservice\backend\backend.csproj.

    NuGet Config files used:
        C:\Users\Tariq Abubaker\AppData\Roaming\NuGet\NuGet.Config
        C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
        C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config

    Feeds used:
        https://api.nuget.org/v3/index.json
        https://nuget.devexpress.com/netconf2019/api
        C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.22
Restored project 'D:\Tariq's Projects\microservice\backend\backend.csproj'.
Build started 21-Aug-20 9:32:04 PM.
__________________________________________________
Project "D:\Tariq's Projects\microservice\backend\backend.csproj" (ResolveReferences;ResolvePackageDependenciesDesignTime;PrepareResources;GetAssemblyAttributes target(s)):


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.20
Found application version: 1.0.0
RunCommand=D:\Tariq's Projects\microservice\backend\bin\Debug\netcoreapp3.1\backend.exe
RunArguments=
TargetPath=D:\Tariq's Projects\microservice\backend\bin\Debug\netcoreapp3.1\backend.dll
PublishDir=bin\Debug\netcoreapp3.1\publish\
AssemblyName=backend
IntermediateOutputPath=obj\Debug\netcoreapp3.1\
Found target framework: netcoreapp3.1
Found shared frameworks: Microsoft.NETCore.App, Microsoft.AspNetCore.App
IsAspNet=True
Evaluation Took: 858.6142ms
Injecting zipkin service...
Injecting elastic service...
Launching Tye Host...

[21:32:06 INF] Executing application from D:\Tariq's Projects\microservice\tye.yaml
[21:32:06 INF] dtrace: Using Zipkin at URL http://localhost:9411
[21:32:06 INF] logs: Using ElasticSearch at http://localhost:9200
[21:32:07 INF] Dashboard running on http://127.0.0.1:8000
[21:32:07 INF] Publishing project D:\Tariq's Projects\microservice\frontend\frontend.csproj
[21:32:07 INF] Publishing project D:\Tariq's Projects\microservice\backend\backend.csproj
An unhandled exception has occurred, how unseemly:
System.InvalidOperationException: Command dotnet dev-certs https -ep C:\Users\Tariq Abubaker\AppData\Local\Temp\qt0yj531.tej\frontend.pfx -p 1c54690d-c283-42ae-b672-a19dd422b4a6 returned exit code -1
   at Microsoft.Tye.ProcessUtil.RunAsync(String filename, String arguments, String workingDirectory, Boolean throwOnError, IDictionary`2 environmentVariables, Action`1 outputDataReceived, Action`1 errorDataReceived, Action`1 onStart, Action`1 onStop, CancellationToken cancellationToken) in /_/src/Microsoft.Tye.Core/ProcessUtil.cs:line 140
   at Microsoft.Tye.ProcessUtil.RunAsync(String filename, String arguments, String workingDirectory, Boolean throwOnError, IDictionary`2 environmentVariables, Action`1 outputDataReceived, Action`1 errorDataReceived, Action`1 onStart, Action`1 onStop, CancellationToken cancellationToken)
   at Microsoft.Tye.Hosting.TransformProjectsIntoContainers.TransformProjectToContainer(Service service, ProjectRunInfo project) in /_/src/Microsoft.Tye.Hosting/TransformProjectsIntoContainers.cs:line 116
   at Microsoft.Tye.Hosting.AggregateApplicationProcessor.StartAsync(Application application) in /_/src/Microsoft.Tye.Hosting/AggregateApplicationProcessor.cs:line 24
   at Microsoft.Tye.Hosting.TyeHost.StartAsync() in /_/src/Microsoft.Tye.Hosting/TyeHost.cs:line 96
   at Microsoft.Tye.Hosting.TyeHost.RunAsync() in /_/src/Microsoft.Tye.Hosting/TyeHost.cs:line 60
   at Microsoft.Tye.Hosting.TyeHost.RunAsync() in /_/src/Microsoft.Tye.Hosting/TyeHost.cs:line 70
   at Microsoft.Tye.Program.<>c.<<CreateRunCommand>b__10_0>d.MoveNext() in /_/src/tye/Program.RunCommand.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Tye.Program.<>c.<<CreateRunCommand>b__10_0>d.MoveNext() in /_/src/tye/Program.RunCommand.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__19_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__10_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseExceptionHandler>b__0>d.MoveNext()
  • The platform (Linux/macOS/Windows)
    Windows 10 Version 2004 (OS Build 19041.388)
@taqabubaker taqabubaker added the bug Something isn't working label Aug 21, 2020
@taqabubaker
Copy link
Contributor Author

I can fix the issue, but I have no idea how to write a test for it.
I'm not sure if we can mock the environment to simulate a Windows machine with a space username 🤷🏻‍♂️ 🤔

@jkotalik
Copy link
Contributor

I can fix the issue, but I have no idea how to write a test for it.

Feel free to submit a PR without a test for now. We'll evaluate if a test is necessary.

@taqabubaker
Copy link
Contributor Author

@jkotalik Thanks.
PR already submitted 👍🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants