Orchard 1.7 publish error: The “MSBuild.Orchard.Tasks.XmlDelete” task could not be loaded from the assembly

Topics: Troubleshooting
Sep 7, 2013 at 6:38 PM
Edited Sep 7, 2013 at 6:40 PM
Hi there,
I have a local Orchard 1.7 cms site, which i have customized and so forth. My task is now to publish my site to my host(arvixe.com) through Visual Studio Ultimate 2012 - via the publish option. But the publish fails and i get this error:
Error   1   The "MSBuild.Orchard.Tasks.XmlDelete" task could not be loaded from the assembly C:\Users\WilliamHolm\Documents\Visual Studio 2012\Projects\whj\src\Orchard.Web\..\Tools\MSBuild.Orchard.Tasks\bin\Release\MSBuild.Orchard.Tasks.dll. Could not load file or assembly 'file:///C:\Users\WilliamHolm\Documents\Visual Studio 2012\Projects\whj\src\Tools\MSBuild.Orchard.Tasks\bin\Release\MSBuild.Orchard.Tasks.dll' or one of its dependencies. The system cannot find the file specified. 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.   C:\Users\WilliamHolm\Documents\Visual Studio 2012\Projects\whj\src\Orchard.Web\Orchard.Web.csproj   247 5   Orchard.Web
by looking at the source where the error is located around line 247, in the Orchard.Web.csproj, it looks like this:
</Target>
  <Import Project="$(ProjectDir)..\..\lib\msbuild\MSBuild.Community.Tasks.Targets" />
  <UsingTask AssemblyFile="$(ProjectDir)..\Tools\MSBuild.Orchard.Tasks\bin\Release\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.XmlDelete" />
  <Target Name="ProcessConfigurationFiles" AfterTargets="CopyAllFilesToSingleFolderForMsdeploy">
    <PropertyGroup>
      <PackageTmp>$(ProjectDir)obj\Release\Package\PackageTmp</PackageTmp>
    </PropertyGroup>
    <!-- extra processing of the staged config files -->
    <XmlUpdate XmlFileName="$(PackageTmp)\web.config" XPath="/configuration/system.web/compilation/@debug" Value="false" />
    <XmlDelete XmlFileName="$(PackageTmp)\web.config" XPath="/configuration/system.web/trust" />
    <XmlUpdate XmlFileName="$(PackageTmp)\web.config" XPath="/configuration/system.web/machineKey/@validationKey" Value="AutoGenerate" />
    <XmlUpdate XmlFileName="$(PackageTmp)\web.config" XPath="/configuration/system.web/machineKey/@decryptionKey" Value="AutoGenerate" />
    <XmlUpdate XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/appender/immediateFlush/@value" Value="false" />
    <XmlUpdate XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/logger/priority/@value" Value="ERROR" />
    <XmlUpdate XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/root/priority/@value" Value="ERROR" />
    <XmlDelete XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/appender[@name='debug-file']" />
    <XmlDelete XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/appender[@name='debugger']" />
    <XmlDelete XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/appender[@name='error-file']/filter" />
    <XmlDelete XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/logger[@name='Orchard.Localization']" />
    <XmlDelete XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/logger[@name='Orchard']" />
    <XmlDelete XmlFileName="$(PackageTmp)\Config\log4net.config" XPath="/log4net/root/appender-ref[@ref='debug-file']" />
    <!-- disable all file monitoring but ExtensionMonitoringCorrdinator to detect new modules/themes -->
    <XmlUpdate XmlFileName="$(PackageTmp)\Config\HostComponents.config" XPath="/HostComponents/Components/Component/Properties/Property[@Name='DisableMonitoring']/@Value" Value="true" />
  </Target>
The closest ting i can find on this problem, is this thread:

http://orchard.codeplex.com/workitem/19688

and i have tried those advices, but it keeps failing.

Is anyone else experiencing this or does anyone have a solution for this?

THX in advance.

/Will.
Sep 9, 2013 at 12:25 PM
Ok, i have found a workaround, if anyone else is experiencing this issue. I locate Orchard.Web folder, right click on it and open it up in WebMatrix and use WebMatrix to publish the site, that apparently runs without errors. So if anyone knows a solution for VS2012 and Orchard 1.7 let me know, so that i don't have to be dependent on WebMatrix.

/Will.
Sep 12, 2013 at 3:38 PM
Edited Sep 12, 2013 at 3:38 PM
Will,

I ran into this same issue. The MSBuild.Orchard.Tasks project is not built when you build Orchard.Web so it may have never been built or the dll may have been wiped out if you cleaned your solution.

In your solution, go to the Tools folder and build the MSBuild.Orchard.Tasks project (make sure it is set to build using the Release configuration) and you should be able to publish. One other thing that I had to do was to close down and reopen Visual Studio to really make this work, not sure why because as long as the MSBuild.Orchard.Tasks.dll is created it would seem like that is unnecessary. Hope this helps in your situation.

Brian
Sep 13, 2013 at 9:18 AM
Edited Sep 13, 2013 at 9:18 AM
thanks for your reply Brian,

I also figured it out, the error was because the file not existed since i had not built the solution in "Release" mode. see my answer her:
http://stackoverflow.com/questions/18646721/orchard-1-7-publish-error-the-msbuild-orchard-tasks-xmldelete-task-could-not/18739467#18739467

Regards

/Will.