             setupPath = path.join(outputDirectory, "#{metadata.productName}Setup.exe")
             setupMsiPath = path.join(outputDirectory, "#{metadata.productName}Setup.msi")
             fs.renameSync(path.join(outputDirectory, 'Setup.exe'), setupPath)
-            fs.renameSync(path.join(outputDirectory, 'Setup.msi'), setupMsiPath) if fs.existsSync(setupMsiPath)
+
+            if fs.existsSync(path.join(outputDirectory, 'Setup.msi'))
+              fs.renameSync(path.join(outputDirectory, 'Setup.msi'), setupMsiPath)
 
           done()
 

          '--loadingGif'
          loadingGif
        ]
                
        if useMono
          args.unshift(path.resolve(__dirname, '..', 'vendor', 'Update-Mono.exe'))
          cmd = monoExe

    ChildProcess.execFile options.cmd, options.args, (error, stdout, stderr) ->
      grunt.log.error(stderr) if stderr
      callback(error)

  locateExecutableInPath = (name) ->
    haystack = _.map process.env.PATH.split(/[:;]/), (x) -> path.join(x, name)
    _.find haystack, (needle) -> fs.existsSync(needle)

  grunt.registerMultiTask 'create-windows-installer', 'Create the Windows installer', ->
    @requiresConfig("#{@name}.#{@target}.appDirectory")

    useMono = false
    [monoExe, wineExe] = _.map(['mono', 'wine'], locateExecutableInPath)

    unless process.platform is 'win32'
      useMono = true
      throw new Error("You must install both Mono and Wine on non-Windows") unless wineExe and monoExe
