coapp / coapp.powershell

ClrPlus Signing
52 stars 43 forks source link

Running Visual Studio with /useenv option breaks projects using CoApp-created packages #105

Open dakotahawkins opened 9 years ago

dakotahawkins commented 9 years ago

Example repository here: https://github.com/dakotahawkins/TestCoApp

Built packages are in the "NuGetPackages" directory, main solution is "TestCoApp.sln".

If you launch Visual Studio 2013 from a command prompt using the "RunVS.bat" file, project link fails because Visual Studio can't find\run mt.exe. This is not an issue launching Visual Studio without the /useenv option, and it isn't an issue when CoApp-created package is not being used.

Here is the error:

1>Link:
1>     Creating library D:\TestCoApp\Debug\ApplicationDLL.lib and object D:\TestCoApp\Debug\ApplicationDLL.exp
1>LINK : fatal error LNK1158: cannot run 'mt.exe'
1>
1>Build FAILED.

Here are the contents of "RunVS.bat":

@echo off
setlocal ENABLEDELAYEDEXPANSION

if "%DEVENVDIR%" == "" (
    if exist "%VS120COMNTOOLS%" (
        call "%VS120COMNTOOLS%vsvars32.bat"
        if ERRORLEVEL 1 (
            echo Unable to initialize Visual Studio 2013 build environment
            GOTO Error
        )
    ) else (
        echo Unable to initialize Visual Studio 2013 build environment
        GOTO Error
    )
)

devenv /useenv

EXIT /B 0
:Error
EXIT /B 1

The reason we want to run this way is because we want to dynamically set an environment variable that is used in our project settings. In this case we would set the environment variable prior to launching Visual Studio with the /useenv option.

dakotahawkins commented 9 years ago

It turns out this is a symptom of Issue #104. Manually editing the redist package and changing the SetEnv task to add a semicolon resolved the error.