Archive

Archive for the ‘Visual Studio’ Category

Enabling CI for .net core using TFS Build

October 10, 2016 Leave a comment

At the moment there is no easy way to implement CI for .net core projects. Ideally it should be published and deployed to individual instances of nano servers, but that might be something beyond the capability of TFS Build.

Should you wish to implement CI for .net core projects on TFS 2015, here are the build steps and scripts that you need.

  1. Step 1: Install .net core
    Download https://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-install-script and either place it inside TFS or else in a central location. This will install and setup the .net Core CLI Runtime for the service account that is used by the build servers
    image
  2. Step 2: Run dotnet restore and dotnet publish
    Download and modify the powershell script found at http://pastebin.com/yyjbGDW9. It assumes that each folder is an individual .net core project that needs to be published. Modify accordingly to your environment

    It is important to add in the OutputDir argument as that defines where the published project goes
    image

    As this builds all the projects, you may also want to check “Continue on error”
    image

  3. Step 3: Deploy to the servers
    You can find the script I use at http://pastebin.com/8jBHz3Zf. Important thing to note is that you need to first stop IIS on the target server before copying the files over as running net core on IIS locks the dll files
    image
Advertisements

Microsoft Team Foundation Server–Undoing checkout for a workspace that no longer exists

February 2, 2016 1 comment

Every once in a while, you get a request from your developer telling you that they have reformatted their machine and unfortunately there is still one or 2 files inside that workspace that they forgot to checkout

Visual studio comes with tools that allows you to undo checkout. Unfortunately it runs from the CLI

  1. Goto the visual studio folder
    cd “C:\Program Files (x86)\Microsoft Visual Studio 14.0”
  2. List workspaces of the user
    tf workspaces /collection:http://mytfsserver:8080/tfs/defaultcollection /owner:JohnDoe

    Collection: http://mytfsserver:8080/tfs/defaultcollection
    Workspace Owner          Computer  Comment
    ——— ————– ——— ————————————————————————————
    JD-PC JohnDoe JD-PC
    JD-PC2     JohnDoe JD-PC2
    JD-PC3    JohnDoe JD-PC3

  3. Figure out which workspace contains the file to undo and fire up the undo command

    tf undo /workspace:JD-PC2;JohnDoe /s:http://mytfsserver:8080/tfs $/Path/To/The/File.cs

if it works, you will get the following reply:

The operation completed successfully.  Because the workspace JD-PC2;JohnDoe is not on this computer, you must perform a separate get operation in that workspace to update it with the changes that have been made on the server.

Selenium WebDriver – Element is not clickable at point

February 2, 2016 Leave a comment

Selenium is a fantastic tool for website automation, you simply nuget it into your .NET project and you will be able to use it to automate testing using Firefox

Nuget link: https://www.nuget.org/packages/Selenium.WebDriver

 

However, if you are upgrading from versions < 2.48 to the latest version, you will realize that a lot of your codes will suddenly throw the following error

OpenQA.Selenium.WebDriverException: Unexpected error. Element is not clickable at point (x, y). Other element would receive the click:

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)

 

This is due to the way Selenium handles Mouse Clicks from version 2.48 onwards, version 2.50 is the currently “safer” version to use

https://github.com/SeleniumHQ/selenium/issues/1202

image

 

Of course all of these does not fix the issues you have with the code, here are some possible ways to fix them

#1: Use SendKeys

SendKeys automatically focuses to the element that it needs to send keys to, however this is restricted to input elements

e.g Element.SendKeys(Keys.Escape)

 

#2 Use MoveToElement

MoveToElement is another way to move focus to the element.

e.g new OpenQA.Selenium.Interactions.Actions(driver).MoveToElement(elem).Perform();

#3 Use Javascript

Javascript allows you to pretty much do anything

e.g. ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(" + elem.Location.X + "," + elem.Location.Y + ")")

 

#4 Use ScrollIntoView

ScrollIntoView is another  possible javascript that you can use

((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);

Nuget quick references

November 11, 2015 Leave a comment

Update-Package –reinstall

Use this to quickly reinstall all of your packages, especially useful when things go wrong

 

Nuget Sources

When you need to add more nuget sources in Visual studio, put a nuget.config file in the same folder as the solution file

the content of the nuget.config file should be

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="Identity* Dev Feed" value="https://www.myget.org/F/identity/" />
    <add key="Nuget" value="https://www.nuget.org/api/v2/" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>

Categories: Visual Studio

Generating SOAP proxy class from wsdl and xsd files

May 11, 2015 Leave a comment

Although JSON notation is getting popular, there are times where all you have are wsdl and xsd files.

In order to generate a useful proxy class so that you can use it in your C# code, Visual Studio packs a useful utility adeptly named wsdl

Usage scenario:

wsdl webservice.wsdl webservice.xsd /out:MyWebService.cs

Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 4.0.30319.33440]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file ‘MyWebService.cs’.

Once the SOAP file is generated, just goto your project and add the cs file to your project

Categories: ASP.NET, Visual Studio

You receive an “Unable to start program ‘http://localhost/. The system cannot find the file specified.” error when debugging

September 26, 2012 Leave a comment

If you are using Visual Studio 2012 and Windows 8, when trying to debug a website hosted on IIS, you may get the error listed above.

 

This is actually known issue and is listed in Microsoft Connect

https://connect.microsoft.com/VisualStudio/feedback/details/758876/visual-studio-2012-unable-to-start-program-error-when-debuging-website-on-win8-ie

 

To work around this, you will need to set your home drive to a local drive and then start Visual Studio

SET HOMEDRIVE=C:
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"

Categories: Visual Studio

Visual Studio 2012–WPF rendering hanging Visual Studio

August 14, 2012 2 comments

In Visual Studio 2012, rendering of the WPF UI is now split into another thread/executable called XDesProc.exe.

 

This opens up a few interesting benefits

  1. If the rendering is taking too much time,
  2. or if the rendering is taking up too much CPU

You can choose to kill it! Simply fire up Task Manager, kill the XDesProc.exe process

image

 

Which will cause you to see this inside Visual Studio

image

 

You can still continue editing XAML, just that you lost the ability to edit the GUI.

Categories: Visual Studio