Visual Studio’s Live Share tool is a lifesaver when working from home…

Everyone knows It’s Corona Time. Like many others, I am working from home.

Here is a new tool that I always ignored that has changed our lives lately.

It’s called LIVE SHARE, a Visual Studio add-on.

Get it from https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsls-vs

This will adda button to the bottom right corner of your VS. You will need an account to login to VS as well. Once setup just start the share. The url will be automatically copied to your clipboard as well!

We have also been using Loom a lot for recording and sharing screens.

 

~ The only difference between monkeys and us are that we know how to use tools. Once they learn how to do that, we are doomed. ~

 

Make Sitecore Look Good Again. Tip #3021: Add CSS to the content tree items

Let’s make Sitecore beautiful. Here is a very little known thing that I personally haven’t seen getting too much attention but is a neat trick to show off your skillz.

Select the Item. Go to the configure tab. Then “Tree node style”. Enter all the CSS styles you know and want to show.

Screen Shot 2020-03-15 at 5.48.49 PM

Be careful: A bit of wrong, weird or malformed CSS could break this. and you will the red screen of death next time you try to go to the Tree Node Style window.

To clean that up I usually spin up http://<your-sitecore>/sitecore/admin/dbbrowser.aspx

and go to the item’s style value and clean that up.

Screen Shot 2020-03-15 at 6.13.47 PM

 

~ Enjoy the colors around you. ~

Make sure all your config file’s build action is set properly in Visual Studio.

One late afternoon, I was working on a client’s Sitecore and trying to deploy some changes through their azure DevOps pipeline.

I had some changes to a config file. But it was not pushing thru to the server. Files were checked in. It was showing up on the repo on the right branch. But the reason the updated changes were not showing up because the config file’s “build action” was set to “none”. In Visual Studio this needs to be set to “Content”.

Visual Studio 2010 : Build Action详解-流o氓的小窝

Another day: Sitecore helix was my new best friend. I was working with 20+ projects in the solution. A big clump of features, foundation, and other things. All of them having their own web.config.

I am sure you had at least one bad day when you left the web.config as content and it overwrote the main config on the root when it’s not supposed to. It was the same issue. Build action has to be set to none.

Remember this. It will come in handy.

Here are the details for all the values:

Build action values

Some of the more common build actions for C# and Visual Basic project files are:

 
Build Action Project types Description
additional files C#, Visual Basic A non-source text file that’s passed to the C# or Visual Basic compiler as input. This build action is mainly used to provide inputs to analyzers that are referenced by a project to verify code quality. For more information, see Use additional files.
ApplicationDefinition WPF The file that defines your application. When you first create a project, this is App.xaml.
CodeAnalysisDictionary .NET A custom word dictionary, used by Code Analysis for spell checking. See How to: Customize the Code Analysis Dictionary
Compile any The file is passed to the compiler as a source file.
Content .NET A file marked as Content can be retrieved as a stream by calling Application.GetContentStream. For ASP.NET projects, these files are included as part of the site when it’s deployed.
design data WPF Used for XAML ViewModel files, to enable user controls to be viewed at design time, with dummy types and sample data.
DesignDataWithDesignTimeCreateable WPF Like DesignData, but with actual types.
Embedded Resource .NET The file is passed to the compiler as a resource to be embedded in the assembly. You can call System.Reflection.Assembly.GetManifestResourceStream to read the file from the assembly.
EntityDeploy .NET For Entity Framework (EF) .edmx files that specify deployment of EF artifacts.
Fakes .NET Used for the Microsoft Fakes testing framework. See Isolate code under test using Microsoft Fakes
None any The file isn’t part of the build in any way. This value can be used for documentation files such as “ReadMe” files, for example.
Page WPF Compile a XAML file to a binary .baml file for faster loading at run time.
Resource WPF Specifies to embed the file in an assembly manifest resource file with the extension .g.resources.
Shadow .NET Used for a .accessor file that contains a list of built assembly filenames, one per line. For each assembly on the list, generate public classes with the names that are just like the originals, but with public methods instead of private methods. Used for unit testing.
Splash Screen WPF Specifies an image file to be displayed at run time when the app is starting up.
XamlAppDef Windows Workflow Foundation Instructs the build to build a workflow XAML file into an assembly with an embedded workflow.

 

~ When life gives you a lemon, add sugar to it. ~

All the Redirect Rules you will ever need in web.config

Force HTTPS redirect (Permanently)

<rule name="Root Hit Force HTTPS Redirection" enabled="false" stopProcessing="true">
    <match url="^$" ignoreCase="false" />
    <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
        <add input="{HTTP_METHOD}" pattern="GET" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/" redirectType="Permanent" />
</rule>

Sitecore Login & Admin Site Force HTTPS Redirection

<rule name="Sitecore Login or Admin Force HTTPS Redirection" enabled="true" stopProcessing="true">
    <match url="^(sitecore/(login|admin))$" />
    <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
        <add input="{HTTP_METHOD}" pattern="GET" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>

Match a pattern and redirect somewhere else

<rule name="Forbidden" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
     <match url="(.*)" />
     <conditions logicalGrouping="MatchAny">
         <add input="{HTTPS}" pattern="^OFF$" />
         <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
     </conditions>
     <action type="Redirect" url="https://destination.com{REQUEST_URI}" appendQueryString="false" />
</rule>

Redirect to non-www site url

<rule name="RedirectWwwToNonWww" stopProcessing="false">
   <match url="(.*)" />
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
       <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
   </conditions>
   <action type="Redirect" url="https://{C:2}{REQUEST_URI}" redirectType="Permanent" />
</rule>

Redirect some domains to another domain

<rule name="all domains to destination" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^destination1.com$" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="^destination2.com$" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://destination.com/{R:1}" />
</rule>

Am I missing some? Let me know and I can add more…

 

~ Delayed gratification is my type of happiness only if I am alive that long. ~

Move old code into new GitHub repo

I am sure you found an old code in your backup hard-drive from 10 years ago. And you trying to remember what you were thinking when you backed up the code off-grid under ground but not leave it in a repo in GitHub. Even if it’s top secret PRISM code, you could still upload it in to a private GitHub repo.

Open git back on the code base root.

To remove a remote:  git remote remove origin

To add a remote:  git remote add origin yourRemoteUrl

then  git push -u origin master

 From there, you can run git init to create a fresh repository.

BADA BING BADA BOOM!

Cloning an AWS Workspace? Can’t create an image from an existing workspace?

Turn it on.

 

We recently had to create a clone of an AWS Workspace. The way to do it is to create an image from an existing workspace. Then create a bundle then use that to spin up a new workspace.

But, the option was grayed out on the actions dropdown.

Screen Shot 2019-08-19 at 2.01.26 PM

 

The solution was to turn them on.

Once the workspace is running and AVAILABLE, the option was active.  Screen Shot 2019-08-19 at 2.01.34 PM

 

Good Luck.

 

 

~ Google is down. Run for your life. ~

Visual Studio – Project Target Framework Not Installed

Image result for project target framework not installed

Seen this before?

Downloading the targeting pack didn’t work? Now you are on the hunt on the internet and finally ended up here?

Go to C:\Program Files (x86)\Microsoft Visual Studio\Installer

run the vs_installer.exe

Remember you have to close all open visual studio instances while this is installing.

when the installation is complete, load up visual studio and your project. all should be well.

 

~ We are all bald under our hair. ~

 

 

 

Access denied! 401.2 Unauthorized. Logon failed due to server configuration.

I have this website I was building with windows authentication.

When I visit the site with IIS hostname everything was like the ending of a Romantic movie where no one dies. But from Visual Studio when I clicked on Start to see the site I was getting the below error like my soul after watching a rom-com. Devastated!

Screen Shot 2018-02-21 at 3.43.30 PM

There are a bunch of solutions to this issue. But the one that I preferred was changing the solution properties.

on the Web tab, set to run with Local IIS and change the project url to use the hostname from IIS. That will keep all the authentication information as expected and the site will show up.

There are other solutions at https://stackoverflow.com/questions/12640048/error-message-401-2-unauthorized-logon-failed-due-to-server-configuration-wh

~ Enjoy your alone time. ~