2

Closed

Access to the path '<>\Company.Project.Web\T4MVC.tt' is denied.

description

- Including a Fix that solves this issue.

I have added my solution to TFS, which has the habit of setting files to readonly. This causes Chirpy to shriek and die with the following last tweet:

---------------------------
System.UnauthorizedAccessException: Access to the path 'S:\Mvc\Sarens.Kracom.Mvc\Sarens.Kracom.Web\T4MVC.tt' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at Microsoft.VisualStudio.Text.Implementation.TextDocument.PerformSave(FileMode fileMode, String filePath, Boolean createFolder)
at Microsoft.VisualStudio.Text.Implementation.TextDocument.Save()
at Microsoft.VisualStudio.Editor.Implementation.VsDocDataAdapter.<Save>b__a()
at Microsoft.VisualStudio.Editor.Implementation.VsDocDataAdapter.Save(Action saver)
at Microsoft.VisualStudio.Editor.Implementation.VsDocDataAdapter.Save(String pszFilename, Int32 fRemember, UInt32 nFormatIndex)
at EnvDTE.ProjectItem.Save(String FileName)
at Zippy.Chirp.Engines.T4Engine.RunT4Template(DTE2 app, String t4TemplateList)
---------------------------
I took a look at the sourcecode and figure you can change the RunT4Template method (in \Engines\T4Engine.cs)

See the second solution, the first (which I removed here) did not quite work.

Closed Dec 5 2011 at 1:56 PM by andyedinborough
Fixed in http://chirpy.codeplex.com/SourceControl/changeset/changes/77f2078c5082

comments

BenGriswold wrote Jan 30 at 7:26 PM

I grabbed the following release and my concerns have been resolved. Many thanks! http://chirpy.codeplex.com/releases/79914/download/322375

andyedinborough wrote Dec 5 2011 at 2:05 PM

Ahhh... sorry. I should read more closely. `RunCustomTool()` is a much better way of doing it. Now in code: http://chirpy.codeplex.com/SourceControl/changeset/changes/f2e290e51f40.

rlarnoeuri wrote Dec 5 2011 at 12:23 PM

I no longer use chirpy; and have since then developed a small add-in; just for running the T4MVC.tt on each build and when asp.net MVC views/controllers are Added/Changed/Renamed/Removed.

See the attached zip file.
In the RunT4OnBuild\bin\Debug folder there is an RunT4OnBuild.vsi to easily install the add-in.

There is still a quirck in that it not always detects the T4MVC.tt file; closing the solution and opening it again (leaving VS2010 running) solves that.

BenGriswold wrote Dec 4 2011 at 4:23 PM

Perforce also marks the T4MVC.tt readonly. I'd like to see this fix applied as well. Thanks.

thnk2wn wrote Nov 1 2011 at 3:35 PM

Same issue here...

rlarnoeuri wrote Aug 12 2011 at 11:27 AM

Ah, found a good solution, and tested it a little more ;-)

ProjectItem projectItem = app.Solution.FindProjectItem(t4Template.Trim());
if (projectItem != null)
{
// see http://msdn.microsoft.com/en-us/library/vslangproj.vsprojectitem.aspx
VSProjectItem vsProjectItem = projectItem.Object as VSProjectItem;
if (vsProjectItem != null)
{
vsProjectItem.RunCustomTool();
continue;
}
// try the old way
if (!projectItem.IsOpen)
{
projectItem.Open();
}
projectItem.Save();
}