I am creating projects from a template using DTE. I want the projects to be s开发者_JS百科igned by a particular .snk file. How to do it programmatically??
please help..!!
Thanks, Girish
What I did is add a new Addin project into my solution and by adding this code:
public void OnConnection(object application, ext_ConnectMode connectMode, objec addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
SetSign(_applicationObject);
}
public void SetSign(DTE2 app)
{
Solution solution = app.Solution;
foreach (Project proj in solution.Projects)
{
if (null != proj.Properties && null != proj.Properties.Item("SignAssembly"))
{
Property projProperty = proj.Properties.Item("SignAssembly");
bool signed = (bool)projProperty.Value;
if (!signed)
{
proj.Properties.Item("AssemblyOriginatorKeyFile").Value = @"C:\Projects\ClassLibrary1\Addins\Tools\mykeyfile.pfx";
proj.Properties.Item("SignAssembly").Value = true;
}
proj.Save();
}
}
}
精彩评论