Friday, November 29, 2013

Automating package restore in Visual Studio, don’t keep NuGet Packages in source control

When developers install NuGet packages and set references to those assemblies then it would be necessary to keep them available during build. On the other side down the road maybe the NuGet packages in your projects need to be upgraded and also keeping more and more binaries in repositories will just consume more space in your local disk and in repository especially for Git or Distributed version control systems (DCVS) which include every version of every file within the repository.

The best way is to enable package restore during build, the feature added since NuGet 2.0 and improved as of NuGet 2.7.

By automating package restore in Visual Studio the build events can handle installing the missing packages which eliminate the necessity of keeping them in repository.

There are two levels which should be set, simply go for ToolsOptions and then try to choose Package Manager 1. Visual Studio is configured to 'Allow NuGet to download missing packages' 2. Visual Studio is configured to 'Automatically check for missing packages during build in Visual Studio'



It’s done, but there is other options too like [MSBuild-Integrated Package Restore] which I’ll point to that in next blog entry.

Share/Bookmark

Friday, November 22, 2013

Adding external assemblies to load with Visual Studio at startup

Needed to add user defined methods for Telerik Reporting to be able to call the methods in expression builder of report, then it was necessary that Visual Studio loads the assembly at startup to make it ready for Telerik Report designer in VS.

Looked into VS configuration file:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.config

Found the probing tag points to PublicAssemblies & PrivateAssemblies:
<probing privatePath="PublicAssemblies;PrivateAssemblies;..."/>

The above paths allows to have access to assemblies other than GAC, in this case, I needed to drop the custom coded assembly in a path which is known for VS.

Also assemblies deployed in PublicAssemblies path appear in the Add Reference dialog box, if you don't like to make them available in the Add Reference list but be known for VS, it should be deployed in PrivateAssemblies path.

Simply found the paths as following:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies

in this special case, I added the following parts in devenv.exe.config

<configSections> ... <section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection , Telerik.Reporting , Version=7.2.13.1016 , Culture=neutral , PublicKeyToken=a9d7983dfcc261be" allowLocation="true" allowDefinition="Everywhere"/> </configSections>

and then added the following part in devenv.exe.config to introduce the external methods functionality to Telerik.Reporting designer.
<Telerik.Reporting> <AssemblyReferences> <add name="MyAssembly" version="1.0.0.0" /> </AssemblyReferences> </Telerik.Reporting>

Now VS loads the assembly and it gets available for Telerik.Reporting as extended methods inside designer.
Share/Bookmark