LIKE US ON FACE BOOK

Thursday, 24 August 2017

Auto restore Nuget packages with TFS Build (Useful for non Visual studio environment like test server)

Procedure to enable automatic nuget restore in VS 2015/2017

> Create a folder with name ".nuget" in the solution root

> Add these 3 files in to ".nuget folder"
1. "nuget.config"
2. "NuGet.exe"
3. "NuGet.targets"

> Add these tag in you all project file by using node pad or by VS(unload project to edit)

1. <NuGetPackageImportStamp></NuGetPackageImportStamp>
    <RestorePackages>true</RestorePackages>

Add this entry inside "<PropertyGroup>" tag.

2. <Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
  </Target>

Add this in "<project>" tag & would be good if these all enties added in ending of tag.

> This step is addtional but recomemded sometimes.
Add a file with named "repositories.config" inside packages folder & refer all libraries "packages.config". if libraries dont have "packages.config", then no need to refer those.

eg:- <?xml version="1.0" encoding="utf-8"?>
<repositories>
  <repository path="..\Myportal\packages.config" />
  <repository path="..\Myportal.UnitTests\packages.config" />
  <repository path="..\\Myportal.Core\packages.config" />
</repositories>

Here "Myportal" is example taken to represnt library.

Monday, 5 June 2017

Creating Context menu Extension for Project wise i.e. (Adding right lick option for project selected) for Visual Studio 2013 & above

> Create a VSIX project
> Add Custom Commad to project(available in extensibility)
> Use "IDM_VS_CTXT_PROJNODE" as ID for parent, as it is most important to specify that its project node.

eg:-

<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>

this is avalaible in <groups>

> handle the action as you want in "call back function" in ".cs file".

and here is some more option if you wanna have,

> Adding a Button to the Solution Explorer Toolbar
use ID as "IDM_VS_TOOL_PROJWIN" as parent id.