mercoledì 26 gennaio 2011

Visual Studio Tips And Tricks

Lavorando con Visual Studio, ti può capitare di incappare in un errore del tipo:

Failed to update Service Reference XX. Error:The components required to enumerate Web references are not installed on this computer. Please re-install Visual Studio.

Come risolvere questo problema senza dover reinstallare tutto (mezza giornata persa)?

Viene in aiuto il vecchio Prompt dei comandi (DOS).
La prima cosa da fare è quella di trovare l'eseguibile di Visual studio (devenv.exe) e lanciarlo da linea di comando con il parametro /? (devenv /?). Così facendo si riceve in output un elenco di parametri che possono essere utilizzati.

  1. Build: Builds the solution or project with the specified solution configuration. For example "Debug". If multiple platforms are possible, the configuration name must be enclosed in quotes and contain platform name. For example: "Debug|Win32".
  2. Clean: Deletes build outputs.
  3. Command: Starts the IDE and executes the command.
  4. Deploy: Builds and then deploys the specified build configuration.
  5. Edit: Opens the specified files in a running instance of this application. If there are no running instances, it will start a new instance with a simplified window layout.
  6. LCID: Sets the default language in the IDE for the UI.
  7. Log: Logs IDE activity to the specified file for troubleshooting.
  8. NoVSIP: Disables the VSIP developer's license key for VSIP testing.
  9. Out: Appends the build log to a specified file.
  10. Project: Specifies the project to build, clean, or deploy. Must be used with Build, Rebuild, Clean, or Deploy.
  11. ProjectConfig: Overrides the project configuration specified in the solution configuration. For example "Debug". If multiple platforms are possible, the configuration name must be enclosed in quotes and contain platform name. For example: "Debug|Win32". Must be used with Project.
  12. Rebuild: Cleans and then builds the solution or project with the specified configuration.
  13. ResetAddin: Removes commands and command UI associated with the specified Add-in.
  14. ResetSettings: Restores the IDE's default settings, optionally resets to the specified VSSettings file.
  15. ResetSkipPkgs: Clears all SkipLoading tags added to VSPackages.
  16. /Run: Compiles and runs the specified solution.
  17. /RunExit: Compiles and runs the specified solution then closes the IDE.
  18. /SafeMode: Launches the IDE in safe mode loading minimal windows.
  19. /Upgrade: Upgrades the project or the solution and all projects in it. A backup of these files will be created as appropriate.
i parametri che servono per fare in modo di ripristinare la configurazione ottimale sono proprio ResetSettings o ResetSkipPkgs. Questo permette di resettare le impostazioni del'IDE. evitando il ripetersi dell'errore.

In conclusione, basta lanciare da linea di comando
devenv /ResetSkipPkgs
oppure
devenv /ResetSkipPkgs
e il problema è risolto.