Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAKE.Deploy WorkDirectory fix #461 #520

Merged
merged 1 commit into from
Aug 25, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/app/Fake.Deploy/Services.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ type FakeDeployService() as self =
if success then port' else 8080

DeploymentAgent.workDir <-
if args <> null && args.Length > 3 then args.[3]
else ConfigurationManager.AppSettings.["WorkDirectory"]
let path =
if args <> null && args.Length > 3 then args.[3]
else ConfigurationManager.AppSettings.["WorkDirectory"]
match Uri.TryCreate(path, UriKind.RelativeOrAbsolute) with
| false, _ -> failwithf "Incorrect path '%s'" path
| true, uri when uri.IsAbsoluteUri -> path
| true, _ ->
let exeLocation = typedefof<FakeDeployService>.Assembly.Location
let directory = IO.Path.GetDirectoryName(exeLocation)
directory @@ path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not simply use IO.Path.GetFullPath?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you install Fake.Deploy as Windows service your CurrentDirectory will be C:\Windows\system32. So if you have relative path in WorkDirectory variable, IO.Path.GetFullPath returns path relative from C:\Windows\system32 what is not intuitive.

I am sure that Fake.Deploy should operates identically in both modes (console & windows service).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point.
Also with GetFullPath Fake.Deploy would operate identically in both modes, as it doesn't change the program logic depending on the mode.
But for ease of use I would also go with the suggested functionality. It should only be well documented.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I do not understand... Could you explain?

Path.GetFullPath method uses current directory and current volume information to fully qualify path. 

So, the result is depend on current directory which is different for our cases.
Or you suggest to temporary change Environment.CurrentDirectory property to exeLocation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean the application operates also consistently with GetFullPath as in either mode, console or windows service, it depends on current directory.
With your suggestion it depends on executable directory. Also consistently in both modes.


let uri = sprintf "http://%s:%i/" serverName port
logger(sprintf "Listening on %s" uri, EventLogEntryType.Information)
logger(sprintf "WorkDirectory is %s" DeploymentAgent.workDir, EventLogEntryType.Information)
nancyHost <- DeploymentAgent.createNancyHost ([| Uri uri |])
nancyHost.Start()

Expand Down