Marketplace
最新
バナーの背景画像
Marketplace ユーザー ガイド
最終更新日 2024年4月16日

Building Activity Packages

UiPath のプラットフォームは .NET Framework 上に構築されているため、すべてのアクティビティは Nuget パッケージ (.nupkg Goから直接アクティビティをダウンロードすると取得するファイル!Marketplace、または UiPath Studio の パッケージ マネージャーのフィードからアクセス)。 ファイルを 1 つの Nuget パッケージにバンドルするために必要なファイルには、次の 4 種類があります。

AssemblyInfo ファイル



Visual Studio 内にプロジェクトを構築する場合は常に、そのプロジェクトのコードが Microsoft Build Engine (別名: MSBuild) によって、他の Windows アプリケーションで使用可能なライブラリである DLL に変換されます。このライブラリのメタデータは、プロジェクトの [プロパティ] セクション内に格納されている 3 つの AssemblyInfo ファイルから取得されたものです。このファイルは、さまざまなレベルのアクティビティ セットに対する情報を提供します。それぞれのファイルを見ていきましょう。

1. AssemblyInfo.cs

[assembly: AssemblyTitle("MyCompany.MyProduct.Activities")]
[assembly: AssemblyDescription("This activity was made using the UiPath Activity Set extension.")]
[assembly: ComVisible(false)]
[assembly: Guid("133E5191-68DA-4F05-9A81-D5CFA16525C8")][assembly: AssemblyTitle("MyCompany.MyProduct.Activities")]
[assembly: AssemblyDescription("This activity was made using the UiPath Activity Set extension.")]
[assembly: ComVisible(false)]
[assembly: Guid("133E5191-68DA-4F05-9A81-D5CFA16525C8")]

AssemblyInfo.cs には、特定のプロジェクト (例: MyCompany.MyProduct) に固有のメタデータが含まれています。

  • AssemblyTitle は、DLL のフレンドリー名を指定します。わかりやすくするために、プロジェクトの名前と一致させます。
  • AssemblyDescription は、アセンブリの特徴と目的を簡単にまとめたものです。

    他のいくつかの属性 (言語設定やバージョン番号など) を含めることができます。アセンブリのすべての属性のリストについては、Microsoft の公式ドキュメントをご覧ください。

  • ComVisibleGuid は既定の属性であり、このプロジェクトの最終的なライブラリを参照しているアプリケーションで使用されます。これらの属性はほとんどのアクティビティでは使用されることがありませんが、その効果について詳しくは、こちらで確認できます。

2. MyCompany.MyProductAssemblyInfo.cs

#if DEBUG
[assembly: AssemblyVersion("1.0.*")]
#else
[assembly: AssemblyVersion("1.0.0")]
#endif#if DEBUG
[assembly: AssemblyVersion("1.0.*")]
#else
[assembly: AssemblyVersion("1.0.0")]
#endif

次のアセンブリ ファイル <our アクティビティ名>AssemblyInfo.cs には、アクティビティ セット全体に固有のメタデータが含まれますが、すべてのプロジェクト間で共有されます。この場合、アクティビティのバージョンのみが対象になります。 Visual Studio の構成ごとにバージョンが異なります。

  • デバッグ: Visual Studio がデバッグ モードの場合、アクティビティはバージョン番号 1.0.* でビルドされます。つまり、メジャー バージョンとマイナー バージョンが設定され (1.0)、ビルドごとにパッチ バージョンが増分されます。これは、同じコードに何度も変更を加える場合に役立ちます。後続のパッケージがそれぞれ新しいバージョンでビルドされても、簡単に区別できるからです。
  • リリース: Visual Studio がリリース モードの場合、バージョン番号が設定されます (例: 1.0.0)。これにより、パッケージの公式リリースの時期を完全に管理できるようになります。



3. GlobalAssemblyInfo.cs

[assembly: AssemblyCompany("MyCompany")]
[assembly: AssemblyProduct("Product A")]
[assembly: AssemblyCopyright("MyCompany © 2019")]
[assembly: AssemblyTrademark("MyCompany™")]
[assembly: AssemblyCulture("en-CA")]
[assembly: NeutralResourcesLanguage("en-US")][assembly: AssemblyCompany("MyCompany")]
[assembly: AssemblyProduct("Product A")]
[assembly: AssemblyCopyright("MyCompany © 2019")]
[assembly: AssemblyTrademark("MyCompany™")]
[assembly: AssemblyCulture("en-CA")]
[assembly: NeutralResourcesLanguage("en-US")]

GlobalAssemblyInfo.cs には、生成するすべてのアクティビティ セット間で共有されるメタデータが含まれています。 たとえば、UiPath.GSuite.Activities パッケージと UiPath.MicrosoftOffice365.Activities パッケージは同じ 企業 (UiPath) によって作成され、同じ 製品 (UiPath Studio) を対象としており、 著作権 商標 言語情報 も同じです。したがって、不要な重複を避けるために同じ GlobalAssemblyInfo.cs ファイルを使用しています。

Nuspec



すべてのプロジェクトが DLL にコンパイルされると、これらのライブラリは UiPath Studio で使用可能な Nuget パッケージにバンドルされます。このパッケージのメタデータは、デザイン プロジェクト内の nuspec ファイルから取得されたものです。

nuspec を介して利用可能なメタデータ要素 の完全なリスト はこちらで確認できますが、まずは以下に示す基本的な例を見てみましょう。 これらの要素は、UiPath Studio のパッケージ マネージャーに表示されるフィールドに対応しており、ユーザーはアクティビティ セットを見つけて区別することができます。

一部の要素 (IDバージョンなど) には、$element$ の形式のタグが含まれています。これらのタグは AssemblyInfo ファイル内の対応するタグから値を取得しており、情報の重複を回避しています。
<?xml version="1.0"?>
<package>
  <metadata>
    <id>$title$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <description>$description$</description>
    <copyright>$copyright$</copyright>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
    <projectUrl>https://integrations.uipath.com/docs/integrating-with-uipath</projectUrl>
    <iconUrl>https://raw.githubusercontent.com/NuGet/Samples/master/PackageIconNuspecExample/icon.png</iconUrl>
    <tags>UiPath Activit</tags>
    <dependencies>
    </dependencies>
  </metadata>
  <files>
    <file src="$OutputPath$**\)\)MyCompany.MyProduct*resources.dll" target="lib\)
et461"/>
  </files>
</package><?xml version="1.0"?>
<package>
  <metadata>
    <id>$title$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <description>$description$</description>
    <copyright>$copyright$</copyright>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
    <projectUrl>https://integrations.uipath.com/docs/integrating-with-uipath</projectUrl>
    <iconUrl>https://raw.githubusercontent.com/NuGet/Samples/master/PackageIconNuspecExample/icon.png</iconUrl>
    <tags>UiPath Activit</tags>
    <dependencies>
    </dependencies>
  </metadata>
  <files>
    <file src="$OutputPath$**\)\)MyCompany.MyProduct*resources.dll" target="lib\)
et461"/>
  </files>
</package>


注: Visual Studio に精通している場合は、実際に AssemblyInfo ファイルと MSBuild だけを使用して独自に Nuget パッケージを構築できます。では、それとは別に nuspec ファイルを使用するのはなぜでしょう。パッケージの所有者ファイルやローカリゼーション ファイルなどの特定のメタデータ プロパティは nuspec でのみ使用可能です。nuspec が必要なのはそのためです。

デザイナー メタデータ



アクティビティが作成され、デザイナー (UI 要素) がビルドされた後、それらのアクティビティとデザイナーは、UiPath Studio の [アクティビティ] パネル に表示されるようリンクされ、メタデータ ストアに登録される必要があります。 以下のコードを使用し、2 つのアクティビティ (親スコープと子アクティビティ) のそれぞれについて次の情報を登録することによって、それらのアクティビティが作成されます。

  • カテゴリ: これらのアクティビティが表示される [アクティビティ] パネルのセクション。既定では、MyCompany > MyProduct に設定されており、Resources.resx のカテゴリ属性を修正することで変更できます。12 行目で、アクティビティ プロジェクトからのクラスと 10 行目で指定したカテゴリがどのようにリンクされているのかを確認します。
  • デザイナー: 対象のアクティビティの UI。13 行目で、アクティビティ プロジェクトからのクラスとデザイン プロジェクトからのクラスがどのようにリンクされているのかを確認します。
  • ドキュメント: アクティビティのオンライン ドキュメント。いずれかの UiPath ワークフローのアクティビティを選択し、F1 を押します。アクティビティのヘルプ ドキュメントが、既定のブラウザーに開きます。14 行目に示すように、このドキュメントの URL がここに指定されます (go.uipath.com がプレースホルダーとして使用されます)。

    namespace MyCompany.MyProduct.Activities.Design
    {
        public class DesignerMetadata : IRegisterMetadata
        {
            public void Register()
            {
                var builder = new AttributeTableBuilder();
                builder.ValidateTable();
                var categoryAttribute =  new CategoryAttribute($"{Resources.Category}");
                builder.AddCustomAttributes(typeof(ParentScope), categoryAttribute);
                builder.AddCustomAttributes(typeof(ParentScope), new DesignerAttribute(typeof(ParentScopeDesigner)));
                builder.AddCustomAttributes(typeof(ParentScope), new HelpKeywordAttribute("https://go.uipath.com"));
                builder.AddCustomAttributes(typeof(ChildActivity), categoryAttribute);
                builder.AddCustomAttributes(typeof(ChildActivity), new DesignerAttribute(typeof(ChildActivityDesigner)));
                builder.AddCustomAttributes(typeof(ChildActivity), new HelpKeywordAttribute("https://go.uipath.com"));
                MetadataStore.AddAttributeTable(builder.CreateTable());
            }
        }
    }namespace MyCompany.MyProduct.Activities.Design
    {
        public class DesignerMetadata : IRegisterMetadata
        {
            public void Register()
            {
                var builder = new AttributeTableBuilder();
                builder.ValidateTable();
                var categoryAttribute =  new CategoryAttribute($"{Resources.Category}");
                builder.AddCustomAttributes(typeof(ParentScope), categoryAttribute);
                builder.AddCustomAttributes(typeof(ParentScope), new DesignerAttribute(typeof(ParentScopeDesigner)));
                builder.AddCustomAttributes(typeof(ParentScope), new HelpKeywordAttribute("https://go.uipath.com"));
                builder.AddCustomAttributes(typeof(ChildActivity), categoryAttribute);
                builder.AddCustomAttributes(typeof(ChildActivity), new DesignerAttribute(typeof(ChildActivityDesigner)));
                builder.AddCustomAttributes(typeof(ChildActivity), new HelpKeywordAttribute("https://go.uipath.com"));
                MetadataStore.AddAttributeTable(builder.CreateTable());
            }
        }
    }


アクティビティ セットをビルドする

前述のファイルが完成したら、アクティビティ セットのビルドは簡単です。[ソリューション エクスプローラー] 内でソリューションを右クリックし、[リビルド] を選択します。



出力パネルに、3 つのプロジェクトすべてのビルドが完了したことを示すメッセージと、バンドルされた nupkg ファイルへのパスが表示されます。



注: アクティビティ パッケージをビルドするには、MyCompany.MyProduct フォルダーまたは MyCompany.MyProduct.Activities.Design プロジェクトを右クリックし、「リビルド」する必要があります。それはなぜでしょうか。次のセクションでビルド後のスクリプトを見てみましょう。

ビルド後のスクリプト

デザイン プロジェクトの [プロパティ] > [ビルド イベント] に移動すると、ビルド後のスクリプトがあります。このスクリプトは、すべてのプロジェクトがビルドされた直後に実行されます。



このスクリプトの最初の行では、混乱を避けるために、出力ディレクトリに存在するパッケージの古いバージョンが削除されます。

2 行目では NuGet のコマンド ライン ツール (nuget.exe) を使用して 3 つのプロジェクトの DLL が 1 つの nuget パッケージに統合されます。このパッケージは UiPath Studio で読み取り可能です。

if exist $(TargetDir)Packages\)\)MyCompany.MyProduct*.* del $(TargetDir)Packages\)\)MyCompany.MyProduct*.*
if $(ConfigurationName) == Debug "$(SolutionDir).nuget\)\)NuGet.exe" pack "$(ProjectPath)" -OutputDirectory "Packages" -IncludeReferencedProjects -Prop Configuration=$(ConfigurationName)if exist $(TargetDir)Packages\)\)MyCompany.MyProduct*.* del $(TargetDir)Packages\)\)MyCompany.MyProduct*.*
if $(ConfigurationName) == Debug "$(SolutionDir).nuget\)\)NuGet.exe" pack "$(ProjectPath)" -OutputDirectory "Packages" -IncludeReferencedProjects -Prop Configuration=$(ConfigurationName)

Was this page helpful?

サポートを受ける
RPA について学ぶ - オートメーション コース
UiPath コミュニティ フォーラム
UiPath ロゴ (白)
信頼とセキュリティ
© 2005-2024 UiPath. All rights reserved.