def mono_build_solution(source, target, env):
    import subprocess
    from shutil import copyfile

    sln_path = os.path.abspath(str(source[0]))
    target_path = os.path.abspath(str(target[0]))

    framework_path = ''
    msbuild_env = os.environ.copy()

    # Needed when running from Developer Command Prompt for VS
    if 'PLATFORM' in msbuild_env:
        del msbuild_env['PLATFORM']

    # Find MSBuild
    if os.name == 'nt':
        msbuild_info = find_msbuild_windows(env)
        if msbuild_info is None:
            raise RuntimeError('Cannot find MSBuild executable')
        msbuild_path = msbuild_info[0]
        framework_path = msbuild_info[1]
        msbuild_env.update(msbuild_info[2])
    else:
        msbuild_path = find_msbuild_unix('msbuild')
        if msbuild_path is None:
            xbuild_fallback = env['xbuild_fallback']

            if xbuild_fallback and os.name == 'nt':
                print('Option \'xbuild_fallback\' not supported on Windows')
                xbuild_fallback = False

            if xbuild_fallback:
                print('Cannot find MSBuild executable, trying with xbuild')
                print('Warning: xbuild is deprecated')

                msbuild_path = find_msbuild_unix('xbuild')

                if msbuild_path is None:
                    raise RuntimeError('Cannot find xbuild executable')
            else:
                raise RuntimeError('Cannot find MSBuild executable')

    print('MSBuild path: ' + msbuild_path)

    # Find NuGet
    nuget_path = find_nuget_windows(env) if os.name == 'nt' else find_nuget_unix()
    if nuget_path is None:
        raise RuntimeError('Cannot find NuGet executable')

    print('NuGet path: ' + nuget_path)

    # Do NuGet restore

    try:
        subprocess.check_call([nuget_path, 'restore', sln_path])
    except subprocess.CalledProcessError:
        raise RuntimeError('GodotSharpTools: NuGet restore failed')

    # Build solution

    build_config = 'Release'

    msbuild_args = [
        msbuild_path,
        sln_path,
        '/p:Configuration=' + build_config,
    ]

    if framework_path:
        msbuild_args += ['/p:FrameworkPathOverride=' + framework_path]

    try:
        subprocess.check_call(msbuild_args, env=msbuild_env)
    except subprocess.CalledProcessError:
        raise RuntimeError('GodotSharpTools: Build failed')

    # Copy files

    src_dir = os.path.abspath(os.path.join(sln_path, os.pardir, 'bin', build_config))
    dst_dir = os.path.abspath(os.path.join(target_path, os.pardir))
    asm_file = 'GodotSharpTools.dll'

    if not os.path.isdir(dst_dir):
        if os.path.exists(dst_dir):
            raise RuntimeError('Target directory is a file')
        os.makedirs(dst_dir)

    copyfile(os.path.join(src_dir, asm_file), os.path.join(dst_dir, asm_file))

    # Dependencies
    copyfile(os.path.join(src_dir, "DotNet.Glob.dll"), os.path.join(dst_dir, "DotNet.Glob.dll"))