Search code examples
wgetnmake

From a build done in nmake, how can I download a file from a URL (wget)?


On Windows, using nmake, how can I include a rule that downloads a file from a location? Something like wget, but on Windows.


Solution

  • On modern Windows (Vista, Windows 7, later), you have Powershell available, so you can do this:

    # ==================================================================
    _PS=${WINDIR}\System32\WindowsPowerShell\v1.0\powershell.exe
    OAUTHCS_URL=https://cropperplugins.svn.codeplex.com/svn/Cropper.Plugins/OAuth1.0/OAuth.cs
    
    OAuth.cs:
        $(_PS) -Command "& {(new-object System.Net.WebClient).DownloadFile('$(OAUTHCS_URL)','OAuth.cs')}"
    

    If you don't like to depend on powershell, you can use a wget command line tool for windows, like this:

    CSC=\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
    
    Oauth.cs: wget.exe 
        .\wget.exe $(OAUTHCS_URL)
    
    wget.exe: wget.cs $(CSC)
        $(CSC) /t:exe /debug+ /out:wget.exe  wget.cs
    

    The source for a usable wget tool is available here.