locked
Visual Studio 2017 Environment Variables Not Working RRS feed

  • Question

  • I am trying to follow the Developing a Custom Rewrite Provider for URL Rewrite Module Microsoft article and I am getting stuck on step 9.

    *Step 9*



    I have tried a few different solutions to get these environment variables to work but I have not had any success. I am using VS 2017 Community Edition. It seems like none of the environment variables for VS are working at all. 

    I have also tried running VsDevCmd.bat which supposedly updates your development variables on your machine but that has not had any effect even with a reboot tossed in. 
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"

    Note: vsvars32.bat supposedly does not exist in VS 2017. I have located vcvars.bat on my system at the following path "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd\ext\vcvars.bat" which it seems like you should use instead. 

    *My Post-build event command line:*

        CALL "%VSAPPIDDIR%..\Tools\vsdevcmd\ext\vcvars.bat" > NULL
        gacutil.exe /if "$(TargetPath)"

    *Error from VS*

    > Error MSB3073 The command "CALL
    > "%VSAPPIDDIR%..\Tools\vsdevcmd\ext\vcvars.bat" > NULL

    > gacutil.exe /if
    > "C:\GIT\IIS-URL-Rewrite-ServerNameProvider\IIS-URL-Rewrite-ServerNameProvider\bin\Debug\netstandard2.0\IIS-URL-Rewrite-ServerNameProvider.dll""
    > exited with code
    > 9009. IIS-URL-Rewrite-ServerNameProvider C:\GIT\IIS-URL-Rewrite-ServerNameProvider\IIS-URL-Rewrite-ServerNameProvider\IIS-URL-Rewrite-ServerNameProvider.csproj 18






    Saturday, September 12, 2020 6:14 PM

All replies

  • Hi ThePieMonster,

    Thank you for posting here.

    According to my understanding, this question seems to be strongly related to IIS, so I suggest that you can ask your question on the IIS.NET Forums for better support.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 14, 2020 2:04 AM
  • The first thing to be aware of is that trying to register an assembly in the GAC at build time requires admin privileges. So that means you need to run VS as an admin. 

    The second issue is that you're calling vcvars.bat which is setting up the C++ command line, not Visual Studio. VS does change the prompt paths with newer versions so you shouldn't use the version that you listed. Go to your Start Menu and find the Visual Studio folder and then go to the properties for the Developer Command Prompt. This will point you to the batch file you should be running for your current version of VS, if it were actually necessary.

    Inside a post build event you use the macros provided to get to files, not environment variables. You cannot actually reference the env vars until after the script you're trying to run has already run. It is a catch-22. To be honest loading that entire script to just run 1 exe is overkill. Since gacutil is installed as a shared component as part of the SDK you can just use the SDK path.

    "$(SDK40ToolsPath)gacutil" /if "$(TargetPath)"


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, September 14, 2020 3:18 PM