Assembly must contain algo type

Created at 03 Mar 2024, 16:43
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
FO

FOREXNUGGETS

Joined 24.12.2023

Assembly must contain algo type
03 Mar 2024, 16:43


Hie kindly assist l am trying to compile a code in visual studio code and l keep getting this error below 

Severity Code Description Project Path File Line Column Source Suppression State
Error CT0002 Assembly must contain algo type. Trial Version C:\Users\Administrator\.nuget\packages\ctrader.automate\1.0.8\build C:\Users\Administrator\.nuget\packages\ctrader.automate\1.0.8\build\cTrader.Automate.targets 47 3 Build 

this is the highlighted part 
<ExtractMetadataTask AssemblyPath="$(TargetPath)"

the target from the below file

***********************************************************************************************
Sdk.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
         created a backup copy.  Incorrect changes to this file will make it
         impossible to load or build your projects from the command-line or the IDE.

Copyright © Spotware Systems Ltd. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
 <_AlgoDirectoryPath>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))</_AlgoDirectoryPath>
 <_AlgoRootDirectoryName>$([System.IO.Path]::GetFileName($(_AlgoDirectoryPath)))</_AlgoRootDirectoryName>
 <_AlgoFileName>$(_AlgoRootDirectoryName).algo</_AlgoFileName>
 <_AlgoFilePath>$(OutDir)$(_AlgoFileName)</_AlgoFilePath>
 <_AlgoMetadataFileName>$(_AlgoFileName).metadata</_AlgoMetadataFileName>
 <_AlgoMetadataFilePath>$(OutDir)$(_AlgoMetadataFileName)</_AlgoMetadataFilePath>
</PropertyGroup>

<PropertyGroup>
 <_TaskAssemblyTFM Condition="'$(MSBuildRuntimeType)' == 'Core'">net6.0</_TaskAssemblyTFM>
 <_TaskAssemblyTFM Condition="'$(MSBuildRuntimeType)' != 'Core'">net472</_TaskAssemblyTFM>
 <_TaskAssembly>$([MSBuild]::Unescape($([System.IO.Path]::GetFullPath('$([MSBuild]::Escape($(MSBuildThisFileDirectory)))..\tools\$(_TaskAssemblyTFM)\cTrader.Automate.Sdk.Tasks.dll'))))</_TaskAssembly>
</PropertyGroup>

<ItemGroup Condition="('$(UseWPF)' == 'True' OR '$(UseWindowsForms)' == 'True') AND ('$(TargetFrameworkVersion)' == 'v6.0' OR '$(TargetFrameworkVersion)' == '6.0')">
 <FrameworkReference Update="Microsoft.WindowsDesktop.App;Microsoft.WindowsDesktop.App.WPF;Microsoft.WindowsDesktop.App.WindowsForms"
                     TargetingPackVersion="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(EnableDefaultAlgoSetItems)' == 'True'">
 <AlgoSet Include="$(MSBuildProjectDirectory)\**\*.cbotset" />
 <AlgoSet Include="$(MSBuildProjectDirectory)\**\*.indicatorset" />
</ItemGroup>

<UsingTask TaskName="ExtractMetadataTask"
           AssemblyFile="$(_TaskAssembly)" />
<UsingTask TaskName="BundleAlgoTask"
           AssemblyFile="$(_TaskAssembly)" />
<UsingTask TaskName="GetAlgoPublishDirTask"
           AssemblyFile="$(_TaskAssembly)" />

<Target Name="_ExtractMetadata"
        DependsOnTargets="FindReferenceAssembliesForReferences">
 <ExtractMetadataTask AssemblyPath="$(TargetPath)"
                      ReferencePath="@(ReferencePathWithRefAssemblies)"
                      AlgoSetFiles="@(AlgoSet)"
                      OutputPath="$(_AlgoMetadataFilePath)" />

 <Message Importance="Normal"
          Text="$(MSBuildProjectName) -> $([System.IO.Path]::GetFullPath($(_AlgoMetadataFilePath)))" />
</Target>

<Target Name="_BundleAlgo"
        DependsOnTargets="ComputeFilesToPublish">
 <BundleAlgoTask FilesToBundle="@(ResolvedFileToPublish)"
                 MetadataPath="$(_AlgoMetadataFilePath)"
                 ProjectDir="$(ProjectDir)"
                 TargetFramework="$(TargetFramework)"
                 IncludeSource="$(IncludeSource)"
                 IncludeSymbols="$(IncludeSymbols)"
                 OutputPath="$(_AlgoFilePath)" />

 <Message Importance="High"
          Text="$(MSBuildProjectName) -> $([System.IO.Path]::GetFullPath($(_AlgoFilePath)))" />
</Target>

<Target Name="_GetAlgoPublishDir">
 <GetAlgoPublishDirTask MetadataPath="$(_AlgoMetadataFilePath)">
  <Output TaskParameter="OutputPath"
          PropertyName="_AlgoPublishDir" />
 </GetAlgoPublishDirTask>
</Target>

<Target Name="_CopyToSources"
        Condition="'$(AlgoPublish)' == 'true'"
        DependsOnTargets="_GetAlgoPublishDir">
 <ItemGroup>
  <_AlgoFile Include="$(_AlgoFilePath)" />
 </ItemGroup>

 <Copy SourceFiles="@(_AlgoFile)"
       DestinationFolder="$(_AlgoPublishDir)"
       OverwriteReadOnlyFiles="True"
       Retries="10"
       RetryDelayMilliseconds="100" />

 <Message Importance="High"
          Text="$(MSBuildProjectName) -> $(_AlgoPublishDir)\$(_AlgoFileName)" />
</Target>

<PropertyGroup>
 <_CoreAlgoBuildTargets>
  _ExtractMetadata;
  _BundleAlgo;
  _CopyToSources;
 </_CoreAlgoBuildTargets>
</PropertyGroup>

<Target Name="_AlgoBuildAfterBuild"
        AfterTargets="Build"
        Condition="'$(AlgoBuild)' == 'true'"
        DependsOnTargets="$(_CoreAlgoBuildTargets)">
</Target>

</Project>


@FOREXNUGGETS
Replies

firemyst
05 Mar 2024, 02:57 ( Updated at: 05 Mar 2024, 06:44 )

Try reading Spotware's documentation and Google:

https://help.ctrader.com/ctrader-automate/compiling/#parameters

 

 


@firemyst

PanagiotisCharalampous
05 Mar 2024, 06:52

Hi there,

Your project needs to have an Algo class in order to compile.

Best regards,

Panagiotis


@PanagiotisCharalampous

FOREXNUGGETS
05 Mar 2024, 06:54 ( Updated at: 05 Mar 2024, 06:58 )

RE: Assembly must contain algo type

firemyst said: 

Try reading Spotware's documentation and Google:

https://help.ctrader.com/ctrader-automate/compiling/#parameters

 

l am asking because its better to be safe than sorry , especially if there is a warning.

Sdk.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
         created a backup copy.  Incorrect changes to this file will make it
         impossible to load or build your projects from the command-line or the IDE.

Copyright © Spotware Systems Ltd. All rights reserved.

 


@FOREXNUGGETS

FOREXNUGGETS
05 Mar 2024, 08:02

RE: Assembly must contain algo type

PanagiotisCharalampous said: 

Hi there,

Your project needs to have an Algo class in order to compile.

Best regards,

Panagiotis

l have added as below but there is a new error message 

using cAlgo.API;
using SKM.V3;
using SKM.V3.Methods;
using SKM.V3.Models;

namespace cAlgo.Robots
{
   [Robot(AccessRights = AccessRights.None)]
   public class CombinedRobot : Robot
   {
       protected override void OnStart()
       {

Severity Code Description Project File Line Suppression State
Error CS5001 Program does not contain a static 'Main' method suitable for an entry point Trial Version C:\Users\Administrator\source\repos\Trial Version\Trial Version\CSC 1 Active
 


@FOREXNUGGETS

PanagiotisCharalampous
05 Mar 2024, 13:29

RE: RE: Assembly must contain algo type

FOREXNUGGETS said: 

PanagiotisCharalampous said: 

Hi there,

Your project needs to have an Algo class in order to compile.

Best regards,

Panagiotis

l have added as below but there is a new error message 

using cAlgo.API;
using SKM.V3;
using SKM.V3.Methods;
using SKM.V3.Models;

namespace cAlgo.Robots
{
   [Robot(AccessRights = AccessRights.None)]
   public class CombinedRobot : Robot
   {
       protected override void OnStart()
       {

Severity Code Description Project File Line Suppression State
Error CS5001 Program does not contain a static 'Main' method suitable for an entry point Trial Version C:\Users\Administrator\source\repos\Trial Version\Trial Version\CSC 1 Active
 

Hi there,

You can just copy and paste code here and there. The point here is that you cannot have a project in your solution that is not a cBot or an indicator.

Best regards,


@PanagiotisCharalampous