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

Notification

Icon
Error

T4 and assembly references
Sane
#1 Posted : Tuesday, August 21, 2012 10:58:59 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/20/2012(UTC)
Posts: 3

Hi,

I have the following issue with NCrucnh building projects with T4.

In our project we heavily use T4 code generation. While simple scenarios works perfect with ncrunch, other breaks ncrunch builds.


We have T4 templates that depends on other project output dlls. The template loads these dlls and use some types defined there.

The issue it that our templates are built using custom Target defined in csproj file named "BeforeCompile". The T4 project looks like:


Code:
<Project xmlns="(- BROKEN LINK -)">
	<PropertyGroup>
		<T4>$(CodeDir)Libs\T4\TextTransform.exe</T4>
    </PropertyGroup>
	<ItemGroup>
		<T4AssemblyFolder Include="$(CodeDir)Main\Project1\bin\$(ConfigurationName)"/> <!-- SIC --->
		<T4AssemblyReference Include="Project1.dll"/>
		<T4AssemblyReference Include="Project2.dll"/>
	</ItemGroup>
	<Target Name="T4DslGen"> 
		<Message Text="Generating..." Importance="high"/> 
		<Exec Command="$(T4) $(T4Input) @(T4IncludeFolder->'-I %(FullPath)',' ') @(T4AssemblyReference->'-r %(FileName)%(Extension)',' ') @(T4AssemblyFolder->'-P %(FullPath)',' ') " />
		<Message Text="Generated." Importance="high"/> 
	</Target>
</Project>


And the T4 target is

Code:
  <Target Name="BeforeCompile">
    <ItemGroup>
      <T4Template Include="Source\LangScriptSource.tt" />
      <SelfProject Include="$(ProjectFileName)">
        <Properties>T4Input=$(ProjectDir)%(T4Template.identity)</Properties>
      </SelfProject>
    </ItemGroup>
    <MSBuild Projects="@(SelfProject)" BuildInParallel="true" Targets="T4DslGen" />
  </Target>


Ncrunch failed with the following:


Source\LangScriptSource.tt (0)#0: Compiling transformation: Metadata file 'Project1.dll' could not be found
Source\LangScriptSource.tt (0)#0: Compiling transformation: Metadata file 'Project2.dll' could not be found

..\..\Libs\T4\T4.targets (33)#7: The command "C:\Users\user\AppData\Local\NCrunch\4548\117\Main\Dsl\..\..\Libs\T4\TextTransform.exe C:\Users\user\AppData\Local\NCrunch\4548\117\Main\Dsl\Source\LangScriptSource.tt -r Project1.dll -r Project2.dll -P C:\Users\user\AppData\Local\NCrunch\4548\117\Main\Dsl\bin\Debug -P C:\Users\user\AppData\Local\NCrunch\4548\117\Main\Project1\bin\Debug " exited with code 1.

It seems that Ncrunch do not copy referenced project output even if "Copy references assemblies in workspace" and "Include static references in workspace" are turned on.

It there any workarroud to get correct output from references projects?

Thanks,
Alex
Remco
#2 Posted : Tuesday, August 21, 2012 11:18:03 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,987

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Alex,

Something to watch out for is that the 'Copy referenced assemblies to workspace' setting only applies at individual project level, so if you haven't tried this already, make sure you try turning it on for all the projects in your solution (as this will make the NCrunch build more closely aligned with the standard one - just watch out for the performance penalty). The configuration view supports multiple selection, which should make this easy to apply. Make sure you reset the NCrunch engine after doing this to make sure the new settings take effect.

Assuming you've tried this, the next thing would be to inspect the workspace of a failed build to identify which files are actually in the workspace. Right click on the failed build in the Tests Window, then go to Advanced->Browse to workspace. This will open an explorer window into the workspace so that you can inspect it after the NCrunch build has failed. Do you notice anything wrong with the workspace itself? Are the dependency DLLs showing in the right places? Are the extra build dependencies (i.e. T4) also showing inside the workspace in the right places?

If the workspace appears correct and without obvious problems, try running a command line MSBuild.exe against the project file that NCrunch has generated. This will give you feedback from an NCrunch-like build without NCrunch being involved, allowing you the freedom to make changes inside the workspace and troubleshoot what is causing the problem.
Users browsing this topic
Guest
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.031 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download