Layer Validation in Visual Studio architecture modeling tools may result in excessive size of user’s temporary folder

When you perform Layer Validation using the tools available from the Architecture menu in Enterprise versions of Visual Studio 2012 and 2013, especially when Layer Validation is part of a Build process, you may find excessive growth of the user’s temporary folder due to caching of binary assemblies. This issue does not affect final release versions Visual Studio 2015.

Problem details

The LmrProvider class is used to access the content of managed assemblies when Layer Validation is performed. Shadow copies of these assemblies are placed in the user’s temporary folder, and may not be removed automatically after the process is complete. This results in rapid growth of the size of the temporary folder, and may eventually lead to problems through long start-up times and shortage of disk space.

Workaround

The temporary folder will have a path and name of the form:

%temp%LmrProviderTempAssemblyFolder

Which is usually:

C:Users<user>AppDataLocalTempLmrProviderTempAssemblyFolder

The simplest workaround is to include a post-build script in your Build process that empties or completely deletes the LmrProviderTempAssemblyFolder folder. By including the script in the post-build event of the .modelproj file, the workaround will be effective from the IDE and from the command line (non-team) build as well.

  1. Unload the modeling project that contains the layer diagram by right clicking on it in Solution Explorer and choosing Unload Project.
  2. Open the project file into the editor by right clicking on it in Solution Explorer and choosing Edit projectname.modelproj.
  3. Add the following property group inside and at the end of the <Project> element (immediately before the closing </Project> tag:

    <PropertyGroup>

    <RunPostBuildEvent>Always</RunPostBuildEvent>

    <PostBuildEvent>rd /s /q $(temp)LmrProviderTempAssemblyFolder 2&gt;nul</PostBuildEvent>

    </PropertyGroup>

  4. Save the project file.
  5. Right click on the modeling project in Solution Explorer and choose Reload Project.

 

More information

For more information about creating post-build scripts, see Run a script in your build process on MSDN.

For more information about Layer Validation, see Validate Code with Layer Diagrams on MSDN.

1