Blacklite / Ncapsulate

NuGet and MSBuild wrappers around various Node based tools.
MIT License
29 stars 9 forks source link

Inconsistently, Task could not be loaded from the assembly #7

Open adamvoss opened 10 years ago

adamvoss commented 10 years ago

This is such a great and useful project! Thank you for making it available to all of us!

I am having a heck of a time consistently recreating this issue, so am posting anyway hoping you might be able to give guidance on how I further can help in getting this resolved as it is preventing me from using the MSBuild steps.

I am getting errors such as the following:

C:\TeamCity\buildAgent\work\691a13f7ed503d0\src\Nile.Billing.Web.Static\App_Build\bower.targets(10, 5): error MSB4062: The "Ncapsulate.Bower.Tasks.BowerInstall" task could not be loaded from the assembly C:\TeamCity\buildAgent\work\691a13f7ed503d0\lib\packages\Ncapsulate.Bower.1.3.3.2\build..\lib\net45\Ncapsulate.Bower.dll. Could not load type 'Ncapsulate.Node.Tasks.NcapsulateTask' from assembly 'Ncapsulate.Node, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I have confirmed the file exists. I am using the stock *.targets added by the NuGet package. The above error is from the build server when I have never had it work; but I have had it both succeed and fail locally without making any changes on my part.

The best work around I have locally is to close Visual Studio and it often times works when I re-open it. Yesterday it was consistently working when I hit 'Build', unless it was after I did a 'Clean' in which case it would give the failure and succeed on the second build. 'Rebuild' would consistently fail. Today I have seen it consistently succeed, then I re-open Visual Studio and it consistently fails; and other such oddities.

I have Visual Studio 2013.3 locally on Windows 8.1. I have Visual Studio 2013 (Update 0, I believe) on Server 2012 for the build machine.

cwoolum commented 10 years ago

I'm running into the same issue except mine does it every time

adamvoss commented 10 years ago

I have had it working consistently everywhere now, but I do not know if it is happenstance and ti will start failing sporadically at some point or if I actually made a correction.

The only NCapsulate task I was needing (thus far) was bower. So my installation was to install it with NuGet which automatically pulled in the node package as a dependency. This was the configuration I was using when I reported this.

The changes I made to have it working were to update the node package to 0.10.28 (it had pulled 10.26 at first). Inspecting the .csproj I noticed that it was listing the bower task before the node task. I manually modified it so that node came first.

The solution has not given me any issues since on my machine, the build machine, or other developers (since it was working I pushed it to our repo). YMMV

This is the relevant part of my *.csproj Not my paths are likely not yours because we use a non-standard path for NuGet packages

  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\..\lib\packages\Ncapsulate.Node.0.10.28\build\Ncapsulate.Node.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\lib\packages\Ncapsulate.Node.0.10.28\build\Ncapsulate.Node.targets'))" />
    <Error Condition="!Exists('..\..\lib\packages\Ncapsulate.Bower.1.3.3.2\build\Ncapsulate.Bower.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\lib\packages\Ncapsulate.Bower.1.3.3.2\build\Ncapsulate.Bower.targets'))" />
  </Target>
  <Import Project="..\..\lib\packages\Ncapsulate.Node.0.10.28\build\Ncapsulate.Node.targets" Condition="Exists('..\..\lib\packages\Ncapsulate.Node.0.10.28\build\Ncapsulate.Node.targets')" />
  <Import Project="..\..\lib\packages\Ncapsulate.Bower.1.3.3.2\build\Ncapsulate.Bower.targets" Condition="Exists('..\..\lib\packages\Ncapsulate.Bower.1.3.3.2\build\Ncapsulate.Bower.targets')" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

NB. by upgrading the Node package you need to modify bower.cmd to correct the path to point to the new version

david-driscoll commented 10 years ago

@vasco3 Has this issue popped back up, or are things pretty good for you now?

@cwoolum Is this still something you've run into? I'm not MSBuild master unfortunately, so it might be something isn't loading right, or maybe the path (assumption) is wrong. I'm not 100% sure.

vasco3 commented 10 years ago

@david-driscoll Node and Gulp are running fine. Do you have any detailed documentation for targets?

peterrus commented 9 years ago

experiencing the same behaviour:

Error   2   The "Ncapsulate.Bower.Tasks.BowerInstall" task could not be loaded from the assembly C:\Users\blaa\Repo\blaa\packages\Ncapsulate.Bower.1.3.12.1\build\..\lib\net45\Ncapsulate.Bower.dll. Could not load type 'Ncapsulate.Node.Tasks.NcapsulateTask' from assembly 'Ncapsulate.Node, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
chr4ss1 commented 9 years ago

Nice library, though, same issue here unfortunately. Latest build.

buzzdan commented 8 years ago

still happens any idea how to solve it?