Surendra Sharma

Surendra Sharma

Search This Blog

Monday, July 13, 2015

The "GeneratePackage" task failed unexpectedly error



If you are trying to set TDS for your Sitecore ASP.NET project and you are getting error The "GeneratePackage" task failed unexpectedly. then its indication that you have not installed TDS correctly.

The detail error is

The "GeneratePackage" task failed unexpectedly.
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at HedgehogDevelopment.SitecoreProject.Tasks.GeneratePackage.Execute()
   at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)          C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets 106                6

How to fix it?

Solution:

Open “C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0” folder and check it must contain below files



If any files are missing then copy all missing files from another colleague or friend computer where TDS is working and paste into your system on the same mentioned folder.

That’s it. Your TDS package will start to work now :)

Please leave your comments or share this trick if it’s useful for you.

Tuesday, July 7, 2015

TDS is unable to generate code for Sitecore "Mulitilist with search" field



I am Sitecorian. I love working on Sitecore. But I usually don't like to access Sitecore items through its field. So I use TDS package to generate entity for each templates.

TDS is great and making my life much easier to write code and allow me to focus on accessing data from Sitecore.

Recently I have added "Mulitilist with search" field in one of my template and I was trying to create corresponding field in code through TDS. 

I generated code but to my surprise I was unable to access it in Sitecore. When I check TDS generated code, I got "Could not find Field Type for Multilist with Search". I tried with some different way to solve this. But didn't succeed. I googled as well but didn't find anything on this.
So I believe this tip is unique in its own as Google don't have answer on this.

I thought that let me check what the corresponding Sitecore class is for Multilist with Search fields.

I didn't found any class. There is only Multilist class is available.



I concluded that if Sitecore have only Multilist class then lets write this field entry in TDS code generated file with Multilist. 

So I added below line

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - Velir.tt", "1.0")]
public CustomMultiListField Non_Applicable_Areas { get { return new CustomMultiListField(InnerItem, InnerItem.Fields[new global::Sitecore.Data.ID("1f21d38a-c061-4d9d-92a6-f9cfba7c3c22")]); } }

Voila. It’s working fine and giving me values in runtime.

Later on I again added some more fields in Sitecore and trying to generate the TDS code. To my surprise my above code was removed by TDS. Then I check the template generated TDS class. I observe that it’s a partial class. So I define that entry in some another file as below

namespace MyProject.Library.TDSTemplates
{
    /// <summary>
    /// Duration
    /// <para></para>
    /// <para>Path: /sitecore/templates/My Project/Component Templates/Animal</para>    
    /// <para>ID: aa5b4a8e-d112-45f1-83f9-fef307938b77</para>
    /// </summary>
    /// <remarks>
    /// This example shows how to specify the <see cref="Animal{T}"/> type as a cref attribute.
    /// </remarks>
    public partial class Animal : global::Sitecore.Data.Items.CustomItem
    {
        /// <summary>
        /// The Non Applicable Areas field.
        /// <para></para>
        /// <para>Field Type: Multilist</para>        
        /// <para>Field ID: 1f21d38a-c061-4d9d-92a6-f9cfba7c3c22</para>
        /// <para>Custom Data: </para>
        /// </summary>
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - Velir.tt", "1.0")]
        public CustomMultiListField Non_Applicable_Areas { get { return new CustomMultiListField(InnerItem, InnerItem.Fields[new global::Sitecore.Data.ID("1f21d38a-c061-4d9d-92a6-f9cfba7c3c22")]); } }

    }
}

OMG J .My code is again working fine and now it’s not removing by TDS code as well.

Please leave your comments or share this tip and code if it’s useful for you.