Monday, December 3, 2018

Run WebServices and Windows services on IIS Express using command prompt or batch file

To run web and windows services in IIS Express through command prompt or batch file, we can create a batch file with the following changes:

cd "C:\Program Files (x86)\IIS Express"
start iisexpress /config:"path to your project source code repository\.vs\config\applicationhost.config" /site:WebSiteName
In applicationhost.config make changes as below:

  • Look for something like below for the WebSiteName above

  <sites>
            <site name="WebSite1" id="1" serverAutoStart="true">

  • Update physicalPath to correct path:

physicalPath="VirtualDirectory of WebSite" /> 

  • or copy all the bin(assembly) files as seen below:
    bin=> has all dll's of the web service
    Web.config should detail the hosting details of all services.




Other Windows services can be started as below:

  1. Create a shortcut to the windows service with command line arguments if any.
  2. In batch file add this line:
  3. start "Service title" /b "Path of shortcut to windowsservice.exe shortcut"



Sunday, November 25, 2018

Visuals Studio - update nuget client

Navigate to your project repository in Dev Command Prompt. 
cd "repository path\.nuget" 
Run this command:
nuget update -self 

Wednesday, October 17, 2018

How to make SlowCheetah work with class libraries and services, apart from executables

Add a App.Base.Config which is the base for all configs and the below lines would ensure on build the specific environment gets copied to the App.config.

Just add the below lines to end of .csProj file where you need SlowCheetah support:

<Import Project="$(SlowCheetahTargets)" Condition="Exists('$(SlowCheetahTargets)')" Label="SlowCheetah" />
  <Import Project="..\packages\Microsoft.VisualStudio.SlowCheetah.3.0.61\build\Microsoft.VisualStudio.SlowCheetah.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.3.0.61\build\Microsoft.VisualStudio.SlowCheetah.targets')" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets" />
  <Target Name="BeforeBuild">
    <TransformXml Source="App.Base.config" Transform="App.$(Configuration).config" Destination="App.config" />
  </Target>

Wednesday, October 10, 2018

Git: Add new files and directories using GitBash

Reference link: 
https://linuxprograms.wordpress.com/2012/01/30/git-add-new-files-directories/
Git: How to add new files and directories?

If you are working with Git and want to add a new file or directory, follow the following steps
Go to the directory where your file is located.
$ cd directory
$ git add filename
Now you must commit these changes (You can give necessary comments)
$ git commit -m "Adding a new file"
If you want to add a directory, Go to the directory where the directory you want to add is located.
$ cd directory
$ git add directoryname
Now you must commit these changes (You can give necessary comments)
$ git commit -m "Adding a new directory"
Note that the above step will also commit the subdirectories and files present in the directory.

Friday, September 14, 2018

All about port usage

 which port is being used by which application, which application uses which port and everything related to this can be found here:
https://dzone.com/articles/how-to-check-which-process-is-using-port-8080-or-a

Wednesday, August 29, 2018

Multiple instances of same windows service on one server

Its possible to host multiple windows service on same server but different name. Here's the link to do it.

Just a small tweak in the code:

        public override void Install(System.Collections.IDictionary stateSaver)
        {
            RetrieveServiceName();
            base.Install(stateSaver);
        }

        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            RetrieveServiceName();
            base.Uninstall(savedState);
        }

        private void RetrieveServiceName()
        {
            var serviceName = Context.Parameters["servicename"];
            if (!string.IsNullOrEmpty(serviceName))
            {
                this._serviceInstaller.ServiceName = serviceName;
                this._serviceInstaller.DisplayName = serviceName;
            }
        }

We can now use this like this:
installutil /servicename=”My Service [SysTest]” d:\pathToMyService\Service.exe
and for uninstall:
installutil /u /servicename=”My Service [SysTest]” d:\pathToMyService\Service.exe
Note for the uninstall you need to supply the servicename so windows how to resolve the service to uninstall

Tuesday, August 28, 2018

Full copy SQL server database from source to destination


1. Copy  databases from source
----------------------------

USE master;
GO 
ALTER DATABASE [DatabaseName]
SET RECOVERY FULL; 

BACKUP DATABASE [DatabaseName]
    TO DISK = 'Backup Location\xyz.bak'  
    WITH FORMAT 
GO  

Copy the back-up file to your destination folder

2. Restore databases at destination
---------------------------------

RESTORE DATABASE [DatabaseName] 
   FROM DISK = 'Backup Location\xyz.bak'  
    WITH RECOVERY,
      MOVE 'xyz' TO  
         'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\Data\xyz.mdf',  
      MOVE 'xyz_log' TO 
         'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\Data\xyz_log.ldf'; 
GO

Restore backed up database with different name at destination
RESTORE DATABASE [DPE-OPL] FROM DISK='D:\DB-Backup\4th Sept 2018\SQL\DPE-OPL-INT.bak'
WITH
MOVE 'DPE-OPL-INT' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\Data\DATA\DPE-OPL.mdf',
MOVE 'DPE-OPL-INT_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\Data\DPE-OPL_log.ldf'

3. Rename the DB in Management Studio

Monday, August 6, 2018

Password protect folder using notepad

Just follow the steps in this link
Line no 21: just give a space after password and before goto FAIL.
In the link they are joined.

Monday, July 2, 2018

TFS Git not tracking remote branch in Visual Studio


Track remote branch
Original problem: Pull disabled in Visual Studio
 git branch -u origin/branchname

Thursday, May 17, 2018

Fix Nuget package errors with Visual Studio 2017 Enterprise

If you face problems accessing/installing the nuget packages from Visual Studio 2017 Enterprise edition, please follow the below steps:

  1. Copy the .nuget folder into the solution folder. It should have 3 files: Nuget.Config, Nuget.exe and Nuget.Targets
  2. Edit Nuget.Config as below:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution> 
  <packageSources> 
       <add key="http_proxy" value="company proxy address" />
       <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> 
       <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> 
       <add key="Local" value="local folder\Nuget Packages\" /> 
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
</configuration>
  1. Close and Exit Visual Studio.

Other way to add proxy entry is to run the following command:
nuget.exe config -set http_proxy=http://my.proxy.address:port
In case you are wondering how to get proxy:

  1. Open chrome, go to below URL to see the proxy details: chrome://net-internals/#proxy
  2. Check Proxy tab on left. Run the PAC script in browser URL
  3. It should download one pac file . Open in notepad. Check for something like this:
if ( host == "abc.com" )
      { return "PROXY IP Address:Port"; }

Thats your proxy.

If this doesn't work, try below:
<system.net>
    <defaultProxy useDefaultCredentials="true" enabled="true">
        <proxy proxyaddress="http://your.proxyserver.ip:port"/>
    </defaultProxy>
    <settings>
        <ipv6 enabled="true"/>
        <servicePointManager expect100Continue="false" />
    </settings>
</system.net>

Wednesday, April 18, 2018

Monday, April 9, 2018

Unable to load the service index for source https://api.nuget.org/v3/index.json

Fix: Run command "dotnet restore"  from Visual Studio version Command Prompt