Cannot create new project (VS2013 and multi-hybrid device app)

此生再无相见时 提交于 2019-12-17 16:43:09

问题


I get the error below when I try to create a new project. I've upgraded to CTP2. Error:

The expression """.Substring(0, 6)" cannot be evaluated. Index and length must refer to a location within the string. Paramter name: length C:\USERS\ME\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets

When this error occurs and I check the solution folder, no project has been created.


回答1:


With VS closed, in a command window, run
npm -g uninstall vs-mda and npm -g uninstall vs-mda-targets

Check to see if this removed the vs-mda and vs-mda-targets folders under
C:\Users\YOUR-USER-NAME\AppData\Roaming\npm\node_modules\
If it didn't, you can delete those folders manually.

Then relaunch VS and create an MDHA project. It should work successfully.

If you get an error on project creation saying that the MDA targets were not found, you can manually install 'vs-mda' & 'vs-mda-targets' from under Visual Studio's Extension folder to get things working again.

Exit Visual Studio and on the drive where Visual Studio is installed, navigate to
%Program Files%\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\uxbwjkun.gjn*\packages
Here you will find two folders "vs-mda" and "vs-mda-targets"

  • Note that uxbwjkun.gjn will not be the exact folder name, but look for something like it that contains packages folder.

Now from here run npm -g install <full path to current folder>\vs-mda and npm -g install <full path to current folder>\vs-mda-targets

When issuing this command it's necessary to give it the explicit path to the vs-mda and vs-mda-targets folders under the VS installation in %Program Files%.

Relaunch and create a new MDHA project.




回答2:


Quite a few of our devs had to solve this one on our team, so I created a script to fix this for them after the upgrade to CTP3. It basically does what Ellen's solution does, but it does it automatically by looking up the Registry entry for the VS Extension path :)

Create a .cmd file with the following contents:

@echo off
setlocal ENABLEEXTENSIONS
echo -- Searching for MultiDeviceHybridApp Visual Studio Extension --
set KEY_NAME=HKEY_USERS\.DEFAULT\Software\Microsoft\VisualStudio\12.0\ExtensionManager\EnabledExtensions
set SEARCH_VALUE=MultiDeviceHybridApp
set REG_QUERY_CMD=reg query "%KEY_NAME%" /f "%SEARCH_VALUE%"
for /f "tokens=2*" %%a in ('%REG_QUERY_CMD% 2^>^&1^|find "REG_"') do @set RESULT_REG_VALUE=%%b
goto find_result_%ERRORLEVEL%
:find_result_0
echo Found here: %RESULT_REG_VALUE%
set PACKAGES_PATH=%RESULT_REG_VALUE%\packages
echo Installing vs mda packages....
echo.
set CMD=npm -g uninstall "%PACKAGES_PATH%\vs-mda-targets"
echo Running: %CMD%
call %CMD%
echo.
set CMD=npm -g uninstall "%PACKAGES_PATH%\vs-mda"
echo Running: %CMD%
call %CMD%
echo.
set CMD=npm -g install "%PACKAGES_PATH%\vs-mda"
echo Running: %CMD%
call %CMD%
echo.
set CMD=npm -g install "%PACKAGES_PATH%\vs-mda-targets"
echo Running: %CMD%
call %CMD%
echo.
echo Done!
goto end
:find_result_1
echo *** Could not find MultiDeviceHybridApp Visual Studio Extension path ***
:end
pause

Run this file and it should uninstall and reinstall the npm packages correctly for you!

PS. You will obviously need npm to be part of your system path.



来源:https://stackoverflow.com/questions/25477665/cannot-create-new-project-vs2013-and-multi-hybrid-device-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!