I was making a new TDS project in my solution today, when I and my team mates faced the following error:
Error The “VerifyTDSVersion” task failed unexpectedly.
System.IO.FileLoadException: API restriction: The assembly ‘file:///C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.Tasks.dll’ has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() TDS.Delta.NoNameRelease C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets 164
I found, 2 solutions for this.
I remember I faced this once, in one of the past projects. I restarted my Visual Studio and it worked. I did the same here, but somehow it didn’t work this time.
We have HedgehogDevelopment.TDS.X.X.X.XX version added to our solution. We have configured Auto Deployment using Team City and Octopus Deploy. When I opened an older TDS project and the new one which was just created, I found a difference! There was a extra line in the old project, which wasnt in my new project.
I found the following extra line:
<Import Project="..\packages\HedgehogDevelopment.TDS.220.127.116.11\build\HedgehogDevelopment.TDS.targets" Condition="Exists('..\packages\HedgehogDevelopment.TDS.18.104.22.168\build\HedgehogDevelopment.TDS.targets')" />
I copied this same line to my new project and the issue that the error got solved.
Conclusion: In case you face an issue regarding TDS projects, its also good to check for whether you have a HedgehogDevelopment.TDS.X.X.X.XX package added via Nuget.
Hope this helps someone in the Sitecore World.
Happy Sitecoring! 🙂