3

The TDS custom validator documentation (https://www.teamdevelopmentforsitecore.com/Blog/custom-tds-validators) details that the validator needs to be placed in the folder C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0. Is it possible to install the validator assembly in a relative location to the solution instead of this folder?

Will the validator still run on the build server?

4

Right now, the validator needs to be there or in the same folder as the tasks assembly for TDS. You can create a pre-build target in the TDS project to copy your assembly into the Nuget package folder if you are using the NuGet package for the TDS build components. We are looking at improving this in a future release.

Here's one way you could do it. Include the following into your scproj file (or in an imported .targets file). (Note: the following assumes only one HedgehogDevelopment.TDS NuGet package folder, and that your custom validators are in a 'MyExtensions.TDS.CustomExtensions' NuGet package and DLL).

  <UsingTask TaskName="GetTdsNuGetPackageFolder" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
    <ParameterGroup>
      <PackagesFolderPath ParameterType="System.String" Required="true" />
      <TdsNuGetFolder ParameterType="System.String" Output="true" />
    </ParameterGroup>
    <Task>
      <Using Namespace="System" />
      <Using Namespace="System.IO" />
      <Using Namespace="System.Text.RegularExpressions" />
      <Code Type="Fragment" Language="cs"><![CDATA[
        var hhogTDSNuGetNamePattern = "HedgehogDevelopment.TDS.*" ;
        var hhogTDSPackageFolders = Directory.EnumerateDirectories(PackagesFolderPath, hhogTDSNuGetNamePattern);
        foreach(var folder in hhogTDSPackageFolders)
        {
            var tasksDllFolder = folder + "/build";
            var tasksFileExists = File.Exists(tasksDllFolder + "/HedgehogDevelopment.SitecoreProject.Tasks.dll");
            if (tasksFileExists)
            {
                TdsNuGetFolder = tasksDllFolder;
                return true;
            }
        }
        TdsNuGetFolder = "";
        ]]></Code>
    </Task>
  </UsingTask>

  <Target Name="BeforeSitecoreBuild">
    <GetTdsNuGetPackageFolder PackagesFolderPath="$(SolutionDir)/packages/">
      <Output TaskParameter="TdsNuGetFolder" PropertyName="TdsNuGetPackageDllFolder" />
    </GetTdsNuGetPackageFolder>

    <Message Condition="$(TdsNuGetPackageDllFolder) == ''"
             Text="Solution doesn't use the HedgehogDevelopment.TDS NuGet package. You need to manually copy the 'packages/MyExtensions.TDS.CustomExtensions.1.0.0.0/build/MyExtensions.TDS.CustomExtensions.dll' to your MSBuild directory (C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0).'" />
    <Message Condition="$(TdsNuGetPackageDllFolder) != ''"
             Text="Solution uses the HedgehogDevelopment.TDS NuGet package. MyExtensions.TDS.CustomExtensions.DLL will load from there." />

    <Copy Condition="Exists('$(TdsNuGetPackageDllFolder)/HedgehogDevelopment.SitecoreProject.Tasks.dll') and !Exists('$(TdsNuGetPackageDllFolder)/MyExtensions.TDS.CustomExtensions.dll')"
          SourceFiles="$(SolutionDir)/packages/MyExtensions.TDS.CustomExtensions.1.0.0.0/build/MyExtensions.TDS.CustomExtensions.dll"
          DestinationFolder="$(TdsNuGetPackageDllFolder)/" />
  </Target>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.