How to Set List Folder Contents

This is a reminder for myself more than anything.

To set "List Folder Contents" on a folder you need to set:

FileSystemRights.ReadAndExecute

InheritanceFlags.ContainerOnly

PropagationFlags.None

 

The only difference between "List Folder Contents" and "Read & Execute" is that List Folder Contents is only inherited by folders rather than by folders and files.

Read More

Update a Dll in the GAC From the Command Line

I’ve blogged before on how to Easily add a dll to the GAC, but that involves two instances of Windows Explorer and the mouse.

It would be quicker and easier to use the command line to update a dll in the GAC. You can do this with the Global Assembly Cache Tool gacutil, but this is only present if you have the .net SDK or Windows SDK installed. This is going to be the case with your development machine, but you don’t really want to be installing it on all your test servers.

To get round this I knocked up a quick utility which will remove an existing version of a dll from the GAC and then install the latest version. The code is:

using System;
using System.Globalization;
using System.EnterpriseServices.Internal;

namespace Test
{
public class GacInstall
{
public static void Main(string[] arguments)
{
try
{
string assemblyPath = arguments[0];
Publish publish = new Publish();
publish.GacRemove(assemblyPath);
publish.GacInstall(assemblyPath);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}

You can then use it by passing it the dll you want as a command line parameter e.g.

GacInstall MyUpdatedCode.dll

Assuming that MyUpdatedCode.dll is in the same directory.

Combined with my last tip Recycle An Individual Application Pool From The Command Line you can now write a bat or cmd file to replace the dll in the GAC and recycle the application pool with 2 key presses: The up arrow key and then return.

Read More

Recycle An Individual Application Pool From The Command Line

When developing SharePoint artifacts which live in the GAC you have the following options to get your new release in as part of the development process:

  1. Build your installation package and upgrade it
  2. Put the new dll in the GAC and run iisreset
  3. Put the new dll in the GAC and recycle the SharePoint application pool
    This is because SharePoint will only pick up updated dlls in the GAC after a recycle.

As it is an iterative process when you are developing this happens a lot, so ideally you need a process which is as quick as possible. 1 & 2 take the longest time so you should aim to use 3.

Luckily there is a command line command which will recycle individual application pools, which will be quicker than using the IIS administration tool. The command is

C:\windows\System32\inetsrv\appcmd.exe recycle apppool "SharePoint – 80"

Where you replace "SharePoint – 80" with the name of your application pool.

Of course when releasing to a live server you should always go down the proper installation package upgrade, this tip is purely for development purposes on your development server.

There’s a lot more you can do with appcmd – it’s a utility for making configuration changes to IIS so pretty much anything you can do through the IIS MMC snap in can be done via it. There are more details about appcmd on Technet or you can run

C:\windows\System32\inetsrv\appcmd.exe /?

to get help details.

Note: appcmd is for IIS7 not IIS6.

Read More