Search code examples
asp.net.netvisual-studio-2015msbuildasmx

ASPNETCOMPILER error while building solution through MSBuild, but successful in Visual Studio


I have one Visual Studio Solution (sln) having around 15 projects.

  1. Some of them are class libraries (.csproj)
  2. Some of them are website projects (.csproj)
  3. Some of them are websites (no .csproj) files

When I build the solution using Visual Studio, it all compiles and builds fine. But when I execute MSBuild from command line it fails for the websites having NO csproj files (i.e., Type 3 projects). I receive following error:

ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'ChilkatDotNet45' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\Users\XXXXXX\Sources\VSTS\Application\XXXXXXX\XXXXXXXScheduler.metaproj]

Could anyone please suggest what could be the reason and how to fix this issue?


Solution

  • ASPNETCOMPILER error while building solution through MSBuild, but successful in Visual Studio

    AFAIK, The ChilkatDotNet45.dll is for the .NET 4.5 Framework, so you should use the MSBuild from Visual Studio 2015:

    C:\Program Files (x86)\MSBuild\14.0\Bin
    

    Not from the .net framework(C:\Windows\Microsoft.NET\Framework\v4.0.30319).

    Besides, if your solution referencing old (v3.5) system assemblies, you also need to updating the <RequiredTargetFramework> values to 4.0 or above in the .csproj.

    See this thread and this thread for some more details.

    Hope this helps.