T4MVC Error - T4 file is blocked or in a non trusted zone

梦想的初衷 提交于 2019-11-30 00:09:40

In Windows Explorer, right click on the file, and choose Properties. At the bottom of the General tab, there should be an "Unblock" button.

This works for me with VS2012:

Using Internet Explorer:

Go to Tools | Internet Options and click the Security tab Under Trusted Sites, click Sites and uncheck “Require https…” Finally add a new entry – it should be the location of your shared folder: “file://folder_name” – note we’re using file instead of https.

This happens to me if I run the project of a shared drive through Parallels.

Windows FIX: Fixed by adding the network drive to trusted web sites. Guide (translated from other language OS)

Open Internet Explorer Open Internet settings Safety pane "Trusted websites" "Websites" Untick "require https for all websites in this zone" Add your network drive like x: For me it added "file://psf" Worked for me.

The site below has a good example of adding the Parallels share to the trusted zone for use with opening a Visual Studio project without warnings. The same technique should remove this warning for T4.

http://blog.florianb.net/2009/10/31/loading-projects-in-visual-studio-using-the-shared-profile-feature-in-parallels/

mjibson

Use the method to add security zones described here. Add your parallels shared folders under the trusted sites section. You may have to uncheck the require HTTPS box.

To allow VS.NET to load things of a network share one needs to add them (shares) to trusted locations. Have a read of this. This will solve the problem for Windows 8 users, when the file is not actually blocked as described above.

To add a location to a full trust list run (obviously amend as required for you environment):

caspol -m -ag 1.2 -url file:///H:/* FullTrust

To verify or list existing trusted locations run:

caspol -lg

It's a file protection thing. The work-around was to create new files of the same name and copying in the text from the old files. Since these files were created on my local computer, there was no conflict.

I had this issue with VS2015 / VS2017 when I copied the .ttinclude files from another project. Creating the new .ttinclude file from the project and renaming them was the only solution.

None of them worked. The source of my problem was, I formatted my pc and in most of my projects, i hardcoded common,modified version of EF's tt. The path was e:.. before formatting.

After formatted, i removed e drive and used d as the same folder. Projects started failing saying that the path is not accesible, right. I created a very small e drive with junction links after, these error messages came...

failed to resolve include text for file:The path '.tt' must be either local to this computer or part of your trusted zone. If you have downloaded this template, you may need to 'Unblock' it using the properties page for the template file in File Explorer.

What i did to resolve was, changing every single path to d drive in tt files:

<#@ include file="d:\BitBucket\Kahia\EF Templates\EF6 ClientModel.tt"#>

it was actually;

<#@ include file="e:\BitBucket\Kahia\EF Templates\EF6 ClientModel.tt"#>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!