Category Archives: Tools

Cloning a GitHub Repo in Visual Studio 2017 …and a Quiz

When showing off some VS2017 features at our VTdotNET meetup, I made a last minute decision to demo the ability to clone a repository right from GitHub. Then I thought I would combine that with other things I planned to demo.

I already had just the right repo sitting in my GitHub account. A small ASP.NET Core project that was built with Visual Studio 2015 using project.json for its metadata. It’s at https://github.com/julielerman/NetCoreSolutionToMigrateToVS2017.

I had this same solution on my laptop already to use for another demo: showing off VS2017’s ability to auto-migrate a project.json based solution to the new csproj based format for .NET Core projects.

Clever me, I decided to kill two birds with one stone. Clone the repo and have the migration run as it was opening that solution.

So I started up Visual Studio 2017 (since I wanted to show how fast that is) and began the process of cloning the solution from my GitHub repo. I already had my credentials set up and was able to go to File, Open and Open from Source Control.

2017-03-21_21-52-52

This opens the Team Explorer window and I clicked the Clone option, which then opened a window showing all of the accounts I’m connected to.

2017-03-21_22-06-28

I expanded my own account and scrolled down to the repo I wanted, selected it and clicked the Clone button.

2017-03-21_22-11-20

The solution got cloned and then it opened up in Visual Studio.

2017-03-21_22-13-53

But it never triggered the migration! And if you look at the solution, you can see that the project I expanded still has its xproj file and its project.json file. At the time I was confused but now that I know what happened, the answer to why this didn’t migrate is very visible in that screenshot of the Solution Explorer. However, one of the developers who was watching this and had just done another demo with Visual Studio 2017, identified the problem quickly.

Let’s move on for some more clues.

I closed the solution. Then from File/Open, I browsed to the place where it had been saved on my computer, and selected the sln file to open. This time, the same exact solution opening up in VS2017, did indeed trigger the migration, which is quite obvious thanks to this screen.

2017-03-21_22-18-17

Then I let the migrate feature do its job. When it was finished, you can see that the project no longer has its xproj and project.json files.

2017-03-21_22-21-42

Now, look at this new Solution Explorer screenshot compared to the previous one.

And then take a look at the list of new VS2017 features in the Release Notes (https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes) under the section IDE and see if you can tell what the cloning did differently when opening the solution than just opening the solution directly from the drive.

Also, I will find out if this is by design or possible a behavior that can get modified to behave the way I had expected. 🙂

Visual Studio Code Snippets to Make Coding EF Core a Little Simpler

I’ve been using the user snippet feature of Visual Studio Code to make it easier to get some of the code I commonly use for EF Core into my files. For example I have C# snippets for DbContext to create a constructor overload that takes in a DbContextOptions parameter, OnConfiguring or OnModeling . I have json snippets to add in the EFCore Commands dependency and the Tools section with EF Core tools.

github.com/julielerman/EFCoreSnippetsForVSCode

I finally created a github repository to share them. Since you’ll need to add the csharp snippets into your existing csharp snippets and the same with the json, i have put them into separate csharp.json and json.json files from which you can copy and past my snippets into your own.

Although the instructions are on the user defined snippets page I just linked to, the TL;DR is:

From menu, choose Code, Preferences then User Snippets

2016-10-30_11-56-58

That will open a list of snippet files. Choose C# for the C# snippets and Json for the Json snippets. Paste in my snippets!

2016-10-30_11-57-25

Video of My .NET on a Mac Demo at DotNetFringe

Last week at the awesome DotNetFringe conference in Portland, Oregon, I did a 30 minute demo of building an ASP.NET Web API with Entity Framework using Visual Studio Code on my lovely MacBookPro. So it’s .NET on a mac (coding, debugging and running). It is *that* cross platform.

I also talked about some of the features of ASPNetCore and EFCore. I used other cross platform stuff like JetBrains’ DataGrip IDE for interacting with numerous databases on numerous platforms, PostgreSQL database, xunit for testing and more!

It was a boatload of fun and it’s on YouTube:

The solution I showed in the demo is in my github repository: julielerman/EFCore-ASPNetCore-WebAPI-RTM

Specifying Global TypeScript server path in Visual Studio Code in OSX

Since I’m really new to working on a mac, the instructions on the VSCode blog post (http://blogs.msdn.com/b/user_ed/archive/2016/02/09/visual-studio-code-new-features-javascript-salsa-preview.aspx) for enabling Salsa for TypeScript in VSCode was just not enough for me. This is the instruction:

You then have to tell VS Code the install location using the typescript.tsdk setting. Set typescript.tsdk to the path of thelib folder containing the tsserver.js file of the installed TypeScript module.

I had done a global install. And since hidden files and the usr/ folder are also a mystery to me, it took me a while to figure out that this is how to specify that in the settings.json file in VSCode.

“typescript.tsdk”: “usr/local/lib/node_modules/typescript/bin/tsserver”

I hope someone can save some time by finding this blog post.

salsa in vscode

Visual Studio 2015 Update 1: EXE Install vs Control Panel Install

tldr; my recommendation is to just do the update from control panel, not from the VS2015.1.exe

If you follow me on twitter (@julielerman) you may have caught one of my tantrum driven tweets yesterday about problems with IISExpress after I updated Visual Studio 2015 to Update 1.

I finally resolved my problems but not after a lot of whining, chocolate and avoidance measures (including a Doctor Who Season 9 episode).

I had been avoiding the update since a number of folks had been complaining about it taking hours and hours but I finally decided to bite the bullet.

I initially updated by downloading the vs2015.1.exe via VS2015 Extensions and running that. It didn’t take too long (20 minutes maybe) but in the end reported that Microsoft .NET Framework 4.6.1 RC Developer Pack had not been installed. This is a known issue. I restarted and installed that and was rewarded with “Successfully installed”.

Then I opened up an ASP.NET MVC5 (*not* the new asp.net) app I’d been working on and tried to run it and so began my problems with IISExpress. Visual Studio could not launch it. I won’t go into the many and various things I tried for the next few hours with hints from friends on twitter and many stackoverflow and blog posts. I even uninstalled and reinstalled IIS 10.0 Express a few times and tried various security/permission tweaks as well. I had offers from friends to jump on skype to help and finally took one of those up – thanks Gregor Suttie (@gsuttie) – though we still made no headway.

There was another strange problem that is noteworthy. Although Visual Studio’s Help/About window showed that I had the version # for Update 1 installed, the Extensions dialog continued to show Update 1 as an available update to Visual Studio. Something wasn’t in sync.

Others on twitter reported issues with Update 1, even Barry Dorrans (@blowdart) who is a security expert on the ASP.NET team and Jeff Prosise (@jprosise), a renowned .NET super duper uber expert.

 

image

image

 

image

 

image

 

image

 

I decided it was time to just uninstall and reinstall VS2015 – cleaner than a repair in my mind. Though I hadn’t yet determined if I would apply the Update 1 again.

I opened up Control Panel/Programs, found Visual Studio Enterprise in the list and selected it. I immediately got a notification that the setup program for Visual Studio had changed significatnly and did I want to update that before making any changes to the installation.

image

Even though my plan had been to uninstall, I decided to take that path. The update took some time … I think over 1/2 hour.

When it was done, Update 1 was one of the options listed when I chose to Modify.

image

FWIW, after performing the update, you can’t uncheck that option.

image

 

I selected the Update 1 and didn’t touch anything else and let ‘er rip (e.g. clicked the Update button).

It took some time to update and it was nice to see that it also brought in the latest version of the EF Designer (6.1.3) for me. “some time” ….I didn’t keep track at all …went upstairs for dinner.

When all was said and done, all of the problems I had seen via the exe install were gone. Update 1 was in place. Extensions no longer prompted me to install the update. I could debug in IISExpress again. All of my other extensions were still in place. (Update: nuget was gone, so I had to reinstall that.)

Oh and I had the new icon which many had fought so hard for:

 image

So my recommendation is to just do the update from control panel, not from the VS2015.1.exe!!

Is Visual Studio Code Bugging You For Your User Name and E-Mail Address?

“Please configure your git user name and e-mail”

Are you seeing this message when trying to push changes from Visual Studio Code to github?

It turns out that all of those times I’d been pushing/pulling from the command prompt and entering my name and email each time could have been avoided with the same configuration. But Visual Studio Code wasn’t going to let me get away with that laziness.

I finally GoogleBinged the message and learned that the configuration is something you need to do from the command prompt.

git config --global user.name yourname
git config --global user.email [email protected]

Diving Into ASP.NET 5 Beta 8? Don’t forget the web tools!

Some developers have been working closely with the evolving ASP.NET 5. Not me. I play with it once in a while. My last time was in the spring with the beta 4. Beta 8 was just released and I was working on creating a Web API. I had two projects in my solution. One was using the ASPNET5 Web API template from Visual Studio 2015.

image

The other used the ASP.NET 5 Class Library project template.

image

The Web API project had a reference to the class library project.

When I attempted to build the solution I got the following two errors that were coming from the Web API project:

CS1703  Multiple assemblies with equivalent identity have been imported: 'C:\Users\jlerm\.dnx\packages\System.Collections\4.0.10\ref\dotnet\System.Collections.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Collections.dll'. Remove one of the duplicate references.
CS1703  Multiple assemblies with equivalent identity have been imported: 'C:\Users\jlerm\.dnx\packages\System.Threading\4.0.10\ref\dotnet\System.Threading.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Threading.dll'. Remove one of the duplicate references.

I won’t bore you with everything I tried to sort this mess out. I finally did find a hack but then ran into another problem at run time — because of changes to web hosting — that was what eventually helped me find the solution to the first problem.

It turns out that the templates were my problem. There are some changes with beta 8 that resulted in the need for new project templates for Visual Studio 2015. They are contained in the ASP.NET and Web Tools 2015 (Beta 8) update for Visual Studio 2015.

You can download them at http://www.microsoft.com/en-us/download/details.aspx?id=49442.

Visual Studio 2015, Command Prompt & Powershell ExecutionPolicy

Just a hint in case you run into this problem that took a few days to discover the pattern.

I have the Productivity Power Tools 2015 installed as an extension to VS2015. These are from Microsoft and there are a ton of features in there that I can’t live without.

With this I can right click on a solution or project in Solution Explorer and open a command prompt at the relevant path.

image

I mostly use this feature to get to posh-git to run some git commands.

posh-git is a PowerShell enhanced environment for the git command line.

image

There are plenty of other reasons you may want to use PowerShell interactively with Visual Studio. Working with ASPNET5 apps is a very good reason.

The problem I encountered was that occasionally, I would get into PowerShell but my Execution-Policy was, for some reason, Restricted, so I couldn’t trigger posh-git.

image

I finally figured out how to ensure I entered the command prompt with my normal Unrestricted ExecutionPolicy.

Be sure to open the Package Manager Console in Visual Studio first. That starts up Powershell with the correct policy. Then when you open your command prompt, you are good to go.

Capture Screenshots Directly into Camtasia Projects

I spend a lot of time in TechSmith’s Camtasia when I’m building my Pluralsight courses. I’ve been using it for years and am a huge devotee. (disclsure that I get a free licnese as a Microsoft MVP but would willingly pay for it). often decide while editing that an image would be handy. I usually have to go grab a screenshot, save that file. Then import that file into my camtasia project and then put it into my video.

I also happen to use TechSmith’s SnagIt for my screen captures (same disclosure re free license and same but I would pay for it for sure!).

I only just discovered that there are a slew of output extensions for Snagit and one of them is Camtasia.

Here is a 30 second video (that I created in Camtasia of course) of how it works.

[youtube http://www.youtube.com/watch?v=6TaLJu-h6iQ?rel=0]