NuGet Packages – Deprecation Information Hidden for Upstream Sources

Discovered this Microsoft ‘feature’ yesterday!
We have set up our own artifact feed for NuGet Packages we have created ourselves. Within this we have defined Nuget.org as an ‘upstream source’ but have recently noticed that deprecation information about packages is for some reason not displayed when viewed as an upstream source ie:

Package Source = NuGet.org:

image.png

Package source = Our own feed with NuGet.org defined as an upstream source:

image.png

Seems a little odd that this is deliberate functionality – after all what benefit would there be to hiding deprecation information? We do have a workaround which is to define Nuget.org as a separate source and then select ‘All’ in the dropdown which gives us the best of both worlds as we can then see our own packages as well as deprecation information. However there does not seem to be any way to make the Package Source dropdown default to ‘All’ as this functionality was apparently removed in Nuget 3.x – https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#activepackagesource
Will be interesting to see what developer community come back with…
https://developercommunity.visualstudio.com/t/Deprecation-Information-hidden-for-Upstr/10481055?viewtype=all

Eliminating duplicates over Multiple Fields using LINQ

Nice little video explaining how to use LINQ to remove duplicates when comparing more than one field in a collection. In this scenario the ‘Distinct’ command is pretty useless! The answer is to do a GroupBy and then select the first record from each group ie:

Temporary Breakpoints

So a new feature with Visual Studio 17.2 is the temporary breakpoint – ie a breakpoint that only activates once then disappears. Confusingly it also appears in brown like a regular breakpoint although it does have a stopwatch timer icon instead of a circle.

Temporary Breakpoint (top)
Regular Breakpoint (bottom)

Time will tell if I actually use them. Can’t really see me using it for new development or bug fixing. Might come in handy for unit testing though…

Aspect Ratio Markup for Video Content

I recently had to add a promotional video to a website using an IFrame and found it really quite fiddly to try and enforce a 16:9 aspect ratio – not only when first rendering the page but also upon re-sizing the browser. This blog post nails it though using css and div containers. Essentially you use padding to define the height of the container as a fixed percentage of the width ie:

  • padding-bottom: 56.25%: The 16:9 aspect ratio corresponds to a height that is 56.25% of the width.

Then you apply another css class to to the IFrame which overrides the padding setting with position: absolute allowing the video to be placed over the padding area:

  • position: absolute: Free the video from the height boundary of its parent and allow it to be positioned over the padding area.

Javascript and Checkboxes

This one always catches me out especially if I havn’t done any javascript for a while! So putting this here as a reminder to myself as much as anything…

Generally with most controls to access the data they are holding you use the .val() syntax ie:

var addressFilename = $(‘#txtChooseFile’).val();

However in order to reference the value of a checkbox you have to specify the ‘checked’ property:

var accountAddress = $(‘#chkAccountAddress’).is(“:checked”);

VS 2015 Issue with Console Apps

Just spent the past couple of days trying to get a legacy VS 2015 console app to debug. But whatever I tried CRM just kept returning the exception message “Unable to Login to Dynamics CRM” which is frankly a horribly generic catch-all error message that could mean absolutely anything!

After investigating and ruling out issues with connections strings, NuGet Packages, tooling connectors and other dependency issues I finally stumbled across this article (see 4th reply from “Justin Jose”) on the Microsoft CRM Dynamics Forum. Turns out there is a bug in VS 2015 and you can’t login to Dynamics via a Console App in debug mode! Thanks Microsoft – that’s two days of my life well spent!!!!

Seems the issue is related to the introduction of TLS 1.2 and does not impact built executables. Indeed running the console app in VS 2017 made the problem go away…

Overloading Controller Actions in MVC

Had an interesting issue yesterday whereby I was getting a 404 “Sorry the resource you are looking for cannot be found” exception raised. However when I debugged the error I found that the resource in question (a razor page) was exactly where it should be! After a lot of head scratching and playing around I finally realised the exception was being raised because unlike all other C# methods you cannot overload a controller action! Hence even though my methods had different signatures MVC couldn’t distinguish between the them.

The following article suggests 3 different ways around the issue.

I chose to use the ActionName decorator which effectively allows you to set up an alternative name for the method. Bear in mind though that you also need to change your calls to the method to use the ActionName. Even still this seemed the cleanest way round the problem whilst preserving some form of overloading:

Authenticating for Artifact Feeds

Recently set up my first Artifact Feed in Azure Devops. However due to an authentication bug I had been unable to connect to it from Visual Studio 2017.

Finally stumbled on this great blog post which answered my prayers! Essentially all you have to do is set up a Personal Access Token with scope to read packages:

PAT Artifact Feed

Then you just include the details of the token in a NuGet.config file. Always simple when you know the answer…