Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "TransformXml" task was not found (error MSB4036) on TeamCity build

Hello I have build server with TeamCity. My project is Sitecore Web Application. I am using TDS (HedgehogDevelopment). I have setup build settings in TeamCity with MS build and it looks like working when TDS project is disabled in build configuration manager. But then it enebled I am getting net error

C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets(310, 5): error MSB4036: The "TransformXml" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Windows\Microsoft.NET\Framework64\v3.5" directory. Project NetKey.TDSMaster\MyProject.TDSMaster.scproj failed. Project Website\MyProject.sln failed

The help in error description is not a case for me. I don't have VS 2012 on build machine. I have installed Microsoft Visual Studio 2012 Shell for support my web project. How to resolve it ? Thanks.

like image 332
Arbejdsglæde Avatar asked May 20 '13 09:05

Arbejdsglæde


4 Answers

TransformXML comes as part of the ASP.NET Web Publishing tools. As such they usually come with a Visual Studio installation on your build server and require more than just the Shell version of Visual Studio. Installing Visual Studio Express Web Edition might also do the trick.

You could try installing the Web-Deploy package to see whether it's enough, but usually I just install the full version of Visual Studio on a build agent. This is legal under MSDN Subscription licensing.

After some experimenting I can tell that you need to install at least the Visual Studio Web Developer Tools on the build server for these tasks to get installed the official way. I suspect that installing the Visual Studio Express Web Edition would suffice.

enter image description here

like image 186
jessehouwing Avatar answered Nov 20 '22 09:11

jessehouwing


Try this:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
like image 31
Choquequirao Avatar answered Nov 20 '22 08:11

Choquequirao


Short Answer - Explicitly Import

What I had to do:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets" Condition="!Exists('$(VSToolsPath)\Web\Microsoft.Web.Publishing.targets')" />

Long Answer

When you do File -> New Web Project in VS2013 you get the following inside your *.csproj file:

<PropertyGroup>
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
  <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

The $(VisualStudioVersion) always evaluated to 11.0 for me on build machines and on multiple development machines. Even on machines with VS2013, which is 12.0.

Diving into that I found that in the Microsoft.WebApplication.targets from above, it has a line to import the file we really want Microsoft.Web.Publishing.targets only if it exists like so on line 377:

<!--Import publishing target-->
<Import Project="..\Web\Microsoft.Web.Publishing.targets" Condition="Exists('..\Web\Microsoft.Web.Publishing.targets')" />

So to me this is an implicit import of Microsoft.Web.Publishing.targets.

The problem is that if this file doesn't exist, it does nothing and you do not know about it until you get the error when trying to use the TransformXml task.

Installing VS2013 did not install Microsoft.Web.Publishing.targets in the 11.0 directory. It did install it in the 12.0 directory. I'm guessing if I installed VS2012, it would do it.

In any case, I was able to solve it by explicitly importing Microsoft.Web.Publishing.targets from the 12.0 directory if it didn't exist and wasn't implicitly imported by Microsoft.WebApplication.targets like so:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets" Condition="!Exists('$(VSToolsPath)\Web\Microsoft.Web.Publishing.targets')" />
like image 20
Rick Glos Avatar answered Nov 20 '22 09:11

Rick Glos


You you have a lots of Visual Studio version, then try this

VS2015

<UsingTask TaskName="TransformXml"
    Condition=" Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.Tasks.dll') "
    AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

VS 2017

<UsingTask TaskName="TransformXml"
    Condition=" Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.Tasks.dll') "
    AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

VS 2019

<UsingTask TaskName="TransformXml"
    Condition=" Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.Tasks.dll') "
    AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

<Target Name="TransformConfig">
    <MakeDir Directories="$(TargetDir)" Condition="  Exists('$(TargetPath)') == False " />
    <TransformXml Source="app.config"
        Transform="app.$(Configuration).config"
        Destination="$(TargetPath).config" />
</Target>

like image 10
Kim Ki Won Avatar answered Nov 20 '22 09:11

Kim Ki Won