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

Notification

Icon
Error

My "Custom Task" gets the wrong directory input in MsBuild
JackWester
#1 Posted : Wednesday, April 4, 2012 12:42:55 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/4/2012(UTC)
Posts: 2
Location: Stockholm, Sweden

Was thanked: 1 time(s) in 1 post(s)
When NCrunch is building my project, it fails to find the input for for a Custom Task. The .csproj employs a Custom Task generating .g.cs files. It seams that it fails to copy the source file.


Code:
<Project xmlns="(- BROKEN LINK -)">

  <PropertyGroup>
    <CoreCompileDependsOn>$(CoreCompileDependsOn);AppOutput</CoreCompileDependsOn>
  </PropertyGroup>
     <ItemGroup>
	  <AvailableItemName Include="App"/>
     </ItemGroup>

  <UsingTask TaskName="JsTemplateToCs.GenerateCodeFromXyzFiles" AssemblyFile="Z:\Dropbox\Starcounter\HelloWeb\JsTemplateToCs\bin\Debug\JsTemplateToCs14.dll" />

  <Target Name="AppOutput" Inputs="@(App)" Outputs="@(App->'$(IntermediateOutputPath)%(FileName)%(Extension).g.cs')">
     <GenerateCodeFromXyzFiles
         InputFiles="@(App)"
         OutputFiles="@(App->'$(IntermediateOutputPath)%(FileName)%(Extension).g.cs')">

        <Output TaskParameter="OutputFiles" ItemName="gFiles" />
 
     </GenerateCodeFromXyzFiles>
	<ItemGroup>
    		<Compile Include="@(gFiles)" />
	  </ItemGroup>
</Target>

</Project>



Code:
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System.IO;
using Starcounter.Template;

namespace JsTemplateToCs
{
   public class GenerateCodeFromXyzFiles : Task, ITask
   {
      [Required]
      public ITaskItem[] InputFiles { get; set; }

      [Output]
      public ITaskItem[] OutputFiles { get; set; }

      public override bool Execute()
      {
         for (int i = 0; i < InputFiles.Length; i++) {
            Log.LogMessage("Creating " + OutputFiles[i].ItemSpec);
            File.WriteAllText(OutputFiles[i].ItemSpec,
                              ProcessXyzFile(
                                 File.ReadAllText(InputFiles[i].ItemSpec)));
         }
         return true;
      }

      private string ProcessXyzFile(string xyzFileContents) {
         return AppTemplate.CreateFromJs(xyzFileContents, false).GenerateCsCode();
      }
   }
}



Code:

NCrunch: If you are experiencing problems in getting this project to build, have a look at https://www.ncrunch.net/documentation/troubleshooting_project-build-issues
C:\Users\Administrator\AppData\Local\NCrunch\3532\8\Starcounter\HelloWeb\HelloWeb\StarcounterApp.targets (13): The "GenerateCodeFromXyzFiles" task failed unexpectedly.
System.IO.FileNotFoundException: [b]Could not find file 'C:\Users\Administrator\AppData\Local\NCrunch\3532\8\Starcounter\HelloWeb\HelloWeb\crm.js'.
File name: 'C:\Users\Administrator\AppData\Local\NCrunch\3532\8\Starcounter\HelloWeb\HelloWeb\crm.js'[/b]
   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, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
   at System.IO.File.ReadAllText(String path)
   at JsTemplateToCs.GenerateCodeFromXyzFiles.Execute() in C:\Dropbox\Starcounter\HelloWeb\JsTemplateToCs\Class1.cs:line 21
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__2f.MoveNext()
JackWester
#2 Posted : Wednesday, April 4, 2012 1:10:51 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/4/2012(UTC)
Posts: 2
Location: Stockholm, Sweden

Was thanked: 1 time(s) in 1 post(s)
Actually, you excellent Wiki link helped me resolve the problem by including the files to copy.

Resolved.
1 user thanked JackWester for this useful post.
Remco on 4/4/2012(UTC)
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.020 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download