5

Is there any way in regular Visual Studio (2017) to view the history of individual yml (unicorn serialization) files? Once you have changed a serialized Sitecore item it appears under the 'Changes' section of the Team Explorer. You can then view the history of files. I would like to be able to just click on any (unchanged) yml file and see its changes directly.

I'm following the Helix pattern and my solution contains for each project a "Code" folder and a "Serialization" folder (like Habitat). The projects (csproj) are visible in the Solution Explorer, but the Serialization files are not. I tried to add a solution folder as a sibling of the project, but there doesn't seem to be a way to make that reference a folder, only individual files. I don't want to add every yml file as that would be a maintenance headache. Is there a better way?

2 Answers 2

5

TIL that Visual Studio 2017 introduced a Solution Explorer toolbar to switch between the classic "Solution" view and to a "Source Files" view which shows the files and folder structure which is on disk.

From the Solution Explorer toolbar, click the Switch Views toolbar icon and select Folder View:

Folder View

You can now see the repository as it is on disk. Expand the folders, find the serialization files, you can now right click each yml file and select View History. You can then double click each entry to view the file at that moment in time, or select 2 entries to compare the differences:

View History

This is extremely handy in Helix based projects and for viewing files not included in the normal Visual Studio Solution, such as Unicorn files and build files for example.

1
  • 1
    Amazing! Thank you for this little gem, I can't believe I didn't know about this feature! Aug 22, 2019 at 8:36
3

The answer to this would depend on what you are using for Source Control. I will try to answer assuming Git is your source control.

Short Answer: Not easily...

The short answer is, with regular Visual Studio and Git as the source, there is no easy way to do this. Sure, you could add VS projects to include the .yml files and do it that way, but that will just clutter up and slow down Visual Studio. There is no point.

Update: There is a way...

Ok - so there is a way, but it may/may not have performance impacts on VS/your builds etc...

Create a new .csproj file and store it in your serialization folder. I called mine Feature.FeatureName.Serialization

Open the .csproj file in notepad/vs code/vim - whatever text editor you use :) and add the following lines:

<ItemGroup>
    <None Include="**\*.yml" />
</ItemGroup>

This will make all the folders and .yml files visible in the project, you can right click and view the history etc... and with them set to None as the build action, it will not copy them.

You will however get a new binary in your bin folder with nothing in... So there is that... I still would just follow the solution below:

Longer Answer: Just don't Use Visual Studio

If you take the requirement to use Visual Studio out of the question, this is a relatively easy task. Depending on your Git client of choice, you just find the files you want and view the history of them. The easiest way to do this is just in Windows File Explorer with GitExtensions. You can simply right click the file and view the history.

If you want something that feels more familiar to Visual Studio users, use Visual Studio Code. Just open the source folder with VS Code and you can view all the files there, it has an excellent Git History plugin that you can install:

enter image description here

Once that is installed, find your file, right click and view the history. See the details about the plugin here: https://github.com/DonJayamanne/gitHistoryVSCode

One of the advantages of Unicorn for me was the removal of all the serialized items from Visual Studio, I would often find that when a TDS project got very large and had lots of items, it would impact on Visual Studio performance. Ultimately, these files are not code and I rarely need to open them up to look at them, I just want to see changes when I make commits. Keeping them out of VS means they don't get in my way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.