Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages12>
T4 Template generation fails in 3.18
smitchamb
#1 Posted : Friday, August 10, 2018 5:59:11 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
We've got a T4 template that is generated as part of the build. In 3.17 this worked fine, but in 3.18 we are getting the following error

Quote:

..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets (340, 5): An Exception was thrown while running the transformation code. The process cannot continue. The following Exception was thrown:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Microsoft.VisualStudio.TextTemplating.CompilerBridge..ctor(String source, Boolean debug, IEnumerable`1 references, String cmdLineArguments)
at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Create(SupportedLanguage language, String source, Boolean debug, IEnumerable`1 references, String cmdLineArguments)
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions)


Is there any setting that may have changed regarding the way package folders are pulled into the build?
Our template runs a process that comes from an exe loaded as a nuget package, so maybe the environment is no longer seeing that process as run from the correct folder?

The VS and MSbuilds are completing and generating code correctly, only the NCrunch build is failing.
Remco
#2 Posted : Saturday, August 11, 2018 1:13:45 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

I can't think of any changes in v3.18 that could be directly responsible for this issue. But the error itself is interesting. The TextTemplating build task under the directory mentioned above seems to have a dependency on Microsoft.CodeAnalysis v2.8, but the file isn't actually collocated with the TextTemplating binaries. Which means that this task has been engineered with the assumption that the Microsoft.CodeAnalysis.dll file is sitting in a search path for the build process. This means the file would probably need to be either in the build directory itself, or otherwise installed in the GAC.

Does turning on the 'Copy referenced assemblies to workspace' setting make any difference in the behaviour you're seeing? Have you had any other changes on your machine other than installing v3.18?
smitchamb
#3 Posted : Monday, August 13, 2018 5:51:22 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
I downgraded and it is still happening, so i must be something in the project related to the code analysis stuff.
Remco
#4 Posted : Tuesday, August 14, 2018 1:01:14 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
smitchamb;12529 wrote:
I downgraded and it is still happening, so i must be something in the project related to the code analysis stuff.


It's not clear to me here what the difference is that causes this to happen in your NCrunch environment and not in others. But resolving the problem should hopefully be as simple as copying the missing binary into the same directory as the .targets file ("Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\TextTemplating") or otherwise installing it in the GAC.

Alternatively, if you're able to share with me a sample project that can demonstrate the issue (you can upload code through the contact form), I can look a bit deeper and try to figure out why this is happening.
smitchamb
#5 Posted : Thursday, August 16, 2018 6:35:14 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
I had recently updated to VS 15.7.6 and now I've updated to 15.8 and my other NCrunch problems are failing to build. Prior to 15.8 this project worked fine. No code changes or other configuration changes have been made.

Quote:

WARNING - ..\..\..\..\program files (x86)\microsoft visual studio\2017\professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets (2110, 5): MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.


Again, the builds work fine and the resharper test runner is able to run these tests fine.
Remco
#6 Posted : Thursday, August 16, 2018 11:15:48 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
It's looking to me like MS have changed some of the assembly resolution logic inside MSBuild as part of the 15.8 update. I've just done some testing on my end to try and reproduce this using the bug report you sent through, but so far I've had no luck in getting it to fail. Is there any chance you can share a minimal code sample that can produce this problem?
smitchamb
#7 Posted : Thursday, August 16, 2018 11:26:10 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
I'll see what I can put together.
1 user thanked smitchamb for this useful post.
Remco on 8/16/2018(UTC)
smitchamb
#8 Posted : Thursday, August 16, 2018 11:31:49 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
The original error has been confirmed in VS 15.7.6 with NCrunch 3.14 and 15.7.5 with NCrunch 3.12. I haven't had a chance to make a minimal implementation of that either, but I'll try to get both tomorrow. I'm pretty crippled without NCrunch.
smitchamb
#9 Posted : Friday, August 17, 2018 2:43:06 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
https://bit.ly/2nIMWBr this link has a zip file with a minimal solution that exposes the issue. I've removed all the nuget packages except for Microsoft.* and System.* and Newtonsoft.Json because ASP.NET depends on it.
Remco
#10 Posted : Friday, August 17, 2018 11:53:52 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks! It looks like this reproduces the problem for me (System.Net.Http resolution). I'll let you know as soon as I have more information. You can remove the download link if you're uncomfortable about having this code online.
Remco
#11 Posted : Saturday, August 18, 2018 4:32:07 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
I've managed to find a solution to this problem. The issue comes from a change introduced in VS 15.8 that forcefully redirects assembly references out to shim assemblies in a different location of the disk. From what I can tell, this appears to affect projects that make use of .NET Standard libraries. The redirection also seems to happen inside NCrunch's loading of projects, so it confuses NCrunch's view of which dependencies are actually required for the project and where they should be referenced from.

I'll publish a build fairly shortly with a fix included ... I'm going to hold it for a few hours to see if there's a way to include a fix for a different VS 15.8 issue in the same build.
Remco
#12 Posted : Sunday, August 19, 2018 4:33:57 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
smitchamb
#13 Posted : Monday, August 27, 2018 8:12:42 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
I loaded 3.19, and in my full project I'm still getting some issues, but only in the Test projects.

One project builds, but fails at runtime due to being unable to find System.Net.Http, other projects are still failing to build. I'm going to dig a little more and then update here.
smitchamb
#14 Posted : Monday, August 27, 2018 9:00:00 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
It looks like this change is related to including System.Runtime nuget package 4.3.0 which has an assembly version of 4.2.1. The projects are actually getting their version from the Visual Studio directory. The version in the NCrunch directory has an assembly version of 4.1.1.0

Quote:

An error occurred while analysing this project after it was built: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Users\smitcham\AppData\Local\NCrunch\83660\7\_ncrunchreferences\System.Runtime.dll' or one of its dependencies. The system cannot find the file specified.
File name: 'file:///C:\Users\smitcham\AppData\Local\NCrunch\83660\7\_ncrunchreferences\System.Runtime.dll'
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.LoadFrom(String assemblyFile)
at nCrunch.Common.CustomAssemblyResolver.(IEnumerable`1 , ParsedAssemblyName )
at nCrunch.Common.CustomAssemblyResolver.ResolveAssembly(ParsedAssemblyName parsedAssemblyName)
at nCrunch.Common.CustomAssemblyResolver.(Object , ResolveEventArgs )
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

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.LoadFrom(String assemblyFile)
at nCrunch.Common.CustomAssemblyResolver.(IEnumerable`1 , ParsedAssemblyName )
at nCrunch.Common.CustomAssemblyResolver.ResolveAssembly(ParsedAssemblyName parsedAssemblyName)
at nCrunch.Common.CustomAssemblyResolver.(Object , ResolveEventArgs )
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)


at Xunit.Sdk.TestFrameworkProxy.GetTestFrameworkType(IAssemblyInfo testAssembly, IMessageSink diagnosticMessageSink)
at Xunit.Sdk.TestFrameworkProxy..ctor(Object testAssemblyObject, Object sourceInformationProviderObject, Object diagnosticMessageSinkObject)$$RethrowMarker$$ at ExceptionExtensions.RethrowWithNoStackTraceLoss(Exception ex)
at Xunit.AppDomainManager_NoAppDomain.CreateObject[TObject](AssemblyName assemblyName, String typeName, Object[] args)
at Xunit.Xunit2Discoverer..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, String assemblyFileName, String xunitExecutionAssemblyPath, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyAssembliesOnDisk)
at nCrunch.Module.XUnit2.Integration.XUnitTestFrameworkContainer.GetDynamicFramework(FilePath assemblyFilePath, DirectoryPath workingDirectory)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.<>c__DisplayClass2_0.<FindFrameworkTestsInAssembly>b__1()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Common.PerformanceTracking.PerfTracker.TryTrackActivity(String name, Action activity)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.TestFinder..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)
smitchamb
#15 Posted : Monday, August 27, 2018 9:02:08 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
For this error flipping the copy reference to workspace flag fixes the build.
Remco
#16 Posted : Tuesday, August 28, 2018 12:23:53 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for sharing these details. The v3.19 build above includes a change that turns off the redirection of assemblies to the VS directory during NCrunch's load of the project, since this was interfering with the identification of the 'true' assemblies being referenced. From our testing and on the sample project that you provided, this looked to have resolved the issue and any downstream problems ... but it seems now like that isn't the case..

Is there any instruction you can give me on how to modify your sample project to produce these other problems? I would hope that it should be possible to get this to work without the 'Copy assembly references to workspace' issue, since this will inhibit your build performance.
smitchamb
#17 Posted : Tuesday, August 28, 2018 1:43:01 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
I'll see if I can cut down the project again leaving one of the test projects in place that is failing and post it.
Remco
#18 Posted : Tuesday, August 28, 2018 10:12:15 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
smitchamb;12583 wrote:
I'll see if I can cut down the project again leaving one of the test projects in place that is failing and post it.


Thanks :) Sorry, I hate asking people to do this. I had a go at arranging a few dependencies around the sample you gave me to try and produce the problem, but had no luck. Maybe this is tied to specific dependencies.
Remco
#19 Posted : Wednesday, August 29, 2018 2:15:11 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
smitchamb
#20 Posted : Thursday, August 30, 2018 7:44:01 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/10/2018(UTC)
Posts: 21
Location: United States of America

Was thanked: 3 time(s) in 3 post(s)
I still need the copy assemblies flag to run the ncrunch build.
Users browsing this topic
Guest
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.127 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download