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

Fix locating kudusync.cmd in Fake.Azure.Kudu #1995

Merged
merged 4 commits into from
Jun 17, 2018
Merged

Fix locating kudusync.cmd in Fake.Azure.Kudu #1995

merged 4 commits into from
Jun 17, 2018

Conversation

nikolaia
Copy link
Contributor

@nikolaia nikolaia commented Jun 12, 2018

Seems to me the current implementation resolves the wrong path. The following script and output is from inside the Kudu-sandbox:

#r "paket:
nuget Fake.Core.Target 
nuget Fake.Azure.Kudu //"
// Use this for IDE support. Not required by FAKE 5.
#load ".fake/deploy.fsx/intellisense.fsx"
open Fake.Core
open Fake.Azure
open Fake.Core.TargetOperators
open Fake.IO
open System.IO
open System
/// The path to the KuduSync application.

Target.create "Old" <| fun _ ->
   (Environment.environVarOrDefault "GO_WEB_CONFIG_TEMPLATE" ".") 
   |> DirectoryInfo.ofPath
   |> fun kuduPath -> Path.Combine(kuduPath.FullName, "kudusync.cmd") 
   |> printfn "%A"

Target.create "New" <| fun _ ->
    (Environment.environVarOrDefault "GO_WEB_CONFIG_TEMPLATE" ".") 
    |> Path.GetDirectoryName
    |> fun kuduPath -> Path.Combine(kuduPath, "kudusync.cmd") 
    |> printfn "%A"

"Old" ==> "New"

Target.runOrDefaultWithArguments "New"

(*
OUTPUT in KUDU shell:

Building project with version: LocalBuild
Shortened DependencyGraph for Target New:
<== New
   <== Old

The running order is:
Group - 1
  - Old
Group - 2
  - New
Starting target 'Old'
NoDescription
"D:\Program Files (x86)\SiteExtensions\Kudu\73.10510.3399\bin\Scripts\go.web.config.template\kudusync.cmd"
Finished (Success) 'Old' in 00:00:00.0185222
Starting target 'New'
NoDescription
"D:\Program Files (x86)\SiteExtensions\Kudu\73.10510.3399\bin\Scripts\kudusync.cmd"
Finished (Success) 'New' in 00:00:00.0005124


*)
D:\home>dir "D:\Program Files (x86)\SiteExtensions\Kudu\73.10510.3399\bin\Scripts\"
 Volume in drive D is Windows
 Volume Serial Number is 4CF9-542E

 Directory of D:\Program Files (x86)\SiteExtensions\Kudu\73.10510.3399\bin\Scripts

06/05/2018  08:37 AM    <DIR>          .
06/05/2018  08:37 AM    <DIR>          ..
06/05/2018  08:37 AM            39,936 CommandLine.dll
06/05/2018  08:37 AM               174 deploy_webjobs.cmd
06/05/2018  08:37 AM            66,419 deployedJob.html.template
06/05/2018  08:37 AM            71,313 dnvm.ps1
06/05/2018  08:37 AM                17 firstDeploymentManifest
06/05/2018  08:37 AM               486 go.web.config.template
06/05/2018  08:37 AM             2,587 iisnode.config.template
06/05/2018  08:37 AM            16,384 KuduHandles.exe
06/05/2018  08:37 AM                49 kudusync
06/05/2018  08:37 AM                66 kudusync.cmd
06/05/2018  08:37 AM            24,064 KuduSync.NET.exe
06/05/2018  08:37 AM               285 KuduSync.NET.exe.config
06/05/2018  08:37 AM         5,331,560 NuGet.exe
06/05/2018  08:37 AM             1,295 runDnxWebJob.cmd
06/05/2018  08:37 AM             2,565 select_python_version.py
06/05/2018  08:37 AM               690 selectLatestVersion.ps1
06/05/2018  08:37 AM            16,624 selectNodeVersion.js
06/05/2018  08:37 AM            33,707 semver.js
06/05/2018  08:37 AM                 5 starter.cmd
06/05/2018  08:37 AM                30 starter.sh
06/05/2018  08:37 AM            23,040 System.IO.Abstractions.dll
              21 File(s)      5,631,296 bytes
               2 Dir(s)   6,450,159,616 bytes free

D:\home> 

@nikolaia nikolaia changed the title Change way of locating kudusync.cmd in Fake.Azure.Kudu Fix locating kudusync.cmd in Fake.Azure.Kudu Jun 12, 2018
@matthid matthid changed the base branch from master to release/next June 13, 2018 19:52
@matthid
Copy link
Member

matthid commented Jun 13, 2018

Can you please merge release/next to get the CI green?

@@ -17,7 +17,7 @@ let nextManifestPath = Environment.environVarOrDefault "NEXT_MANIFEST_PATH" Stri
/// Used by KuduSync for tracking and diffing deployments.
let previousManifestPath = Environment.environVarOrDefault "PREVIOUS_MANIFEST_PATH" String.Empty
/// The path to the KuduSync application.
let kuduPath = (Environment.environVarOrDefault "GO_WEB_CONFIG_TEMPLATE" ".") |> DirectoryInfo.ofPath
let kuduPath = (Environment.environVarOrDefault "GO_WEB_CONFIG_TEMPLATE" ".") |> Path.GetDirectoryName
Copy link
Member

Choose a reason for hiding this comment

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

But this is incorrect if we fallback to the default of ., correct?

Copy link
Contributor Author

@nikolaia nikolaia Jun 14, 2018

Choose a reason for hiding this comment

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

Same script as above in the PR with "."

Starting target 'Old'
NoDescription
"D:\home\kudusync.cmd"
Finished (Success) 'Old' in 00:00:00.1062350
Starting target 'New'
NoDescription
"kudusync.cmd"
Finished (Success) 'New' in 00:00:00.0003611

There is no kudusync.cmd in D:\home, but there is an kudusync.cmd in the PATH variable 🤔 Old fallback doesn't make to much sense to me, but I can fix it to return the same (since some people may be dependent on it, and I don't wanna break it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

FileName = Path.Combine(kuduPath.FullName, "kudusync.cmd")
Arguments = sprintf """-v 50 -f "%s" -t "%s" -n "%s" -p "%s" -i ".git;.hg;.deployment;deploy.cmd""" deploymentTemp deploymentTarget nextManifestPath previousManifestPath })
FileName = Path.Combine(kuduPath, "kudusync.cmd")
Arguments = sprintf """-v 50 -f "%s" -t "%s" -n "%s" -p "%s" -i ".git;.hg;.deployment;deploy.cmd" """ deploymentTemp deploymentTarget nextManifestPath previousManifestPath })
Copy link
Member

Choose a reason for hiding this comment

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

Another way would be to build an array and use Args.toWindowsCommandLine to properly handle all the escaping ugliness of windows

Copy link
Contributor Author

@nikolaia nikolaia Jun 14, 2018

Choose a reason for hiding this comment

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

Done. Works great:

2018-06-14T12:48:17.8474026Z : D:\Program Files (x86)\SiteExtensions\Kudu\74.10611.3437\bin\Scripts\kudusync.cmd "-v" "50" "-f" "D:\local\Temp\8d5d1f4f73e61d1" "-t" "D:\home\site\wwwroot" "-n" "D:\home\site\deployments\1ad4a3db64f24589945de5ab0db7cd6a\manifest" "-p" "D:\home\site\deployments\f54a08fb6cce467cb1e8427e9c6a6337\manifest" "-i" ".git;.hg;.deployment;deploy.cmd"

@matthid
Copy link
Member

matthid commented Jun 17, 2018

Thanks for taking care of this!

@matthid matthid merged commit 79fdc8e into fsprojects:release/next Jun 17, 2018
@nikolaia nikolaia deleted the fix_kudusync_path branch June 18, 2018 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants