共用方式為


升級 WCF 伺服器端專案,以在 .NET 6 上使用 CoreWCF

重要

本文是在 Visual Studio 升級小幫手延伸模組發行之前撰寫的,並使用舊版 CLI 工具。 如需詳細資訊,請參閱使用舊版 .NET 升級小幫手

.NET 升級小幫手是命令列工具,可協助升級 .NET Framework 上現有的 WCF 伺服器端專案,以在 .NET 6 上使用 CoreWCF 服務。 本文提供:

  • 開始須知。
  • 示範如何對 .NET Framework 上的 WCF 伺服器端專案執行此工具。
  • 疑難排解秘訣。

如需如何安裝此工具的詳細資訊,請參閱使用舊版 .NET 升級小幫手

開始須知

此工具目前支援 C# 專案,並使用 CoreWCF 將自我裝載的 WCF 伺服器端專案,移植到 .NET 6。

符合此升級的 WCF 專案必須符合下列需求:

  1. 包含參考 System.ServiceModel 並會建立新 ServiceHost 的 .cs 檔案。

    WCF 專案如有多個 ServiceHost,則所有主機都必須使用相同的方法建立。

  2. 包含儲存 System.ServiceModel 屬性的 .config 檔案。

此工具的目前版本不支援透過 .svc 檔案裝載的 WCF 專案。

注意

若您的專案不適用於此工具,建議您參閱 CoreWCF 逐步解說指南BeanCore 範例示範,然後手動更新專案。

示範應用程式

您可以使用基本計算機範例專案,使用升級小幫手測試升級,這也是此文件所使用的示範。

若要試試更複雜的範例,請參閱 Mike Rousos 建立的 Bean Blob 範例

執行升級小幫手

開啟終端,然後瀏覽至目標專案或解決方案所在的資料夾。 執行 upgrade-assistant upgrade 命令,傳入您要升級的專案或解決方案名稱。

當一提供專案,便會隨即開始專案的升級流程。 若是提供解決方案,您需要選取您日常執行的專案,稱為升級進入點。 接著會依據專案建立相依性關係圖,並提供專案升級順序的建議。

upgrade-assistant upgrade .\CalculatorSample.sln

此工具會執行並列示其所要執行的步驟。 完成每個步驟時,此工具會提供一組命令,讓使用者能夠套用或略過下一個步驟或部分其他選項,包括:

  • 取得有關此步驟的詳細資訊。
  • 變更專案。
  • 調整記錄設定。
  • 停止升級並結束。

Enter 而不選擇數字會選取清單中的第一個項目。

當每個步驟初始化時,它可能提供其認為將在您套用步驟時發生之狀況的相關資訊。

選取要升級的進入點和專案

升級基本計算機範例的第一個步驟,是從解決方案中,選擇要作為進入點專案的專案。

Upgrade Steps

1. [Next step] Select an entrypoint
2. Select project to upgrade

Choose a command:
   1. Apply next step (Select an entrypoint)
   2. Skip next step (Select an entrypoint)
   3. See more step details
   4. Configure logging
   5. Exit

選擇 [命令 1],以啟動該步驟。 結果會隨即顯示:

[10:25:42 INF] Applying upgrade step Select an entrypoint
Please select the project you run. We will then analyze the dependencies and identify the recommended order to upgrade projects.
   1. CalculatorClient
   2. CalculatorService

共列出兩個專案。 因為我們的工具會升級伺服器端專案,所以我們要選擇 [命令 2],以選取服務專案作為進入點。

升級專案

選取專案之後,會列出工具將採取之升級步驟的清單。

重要

您不一定會看到此範例中所列的每個步驟,視根您要升級的專案而定。

下列輸出描述升級專案涉及的步驟:

Upgrade Steps

Entrypoint: C:\Users\Desktop\CalculatorSample\CalculatorService\CalculatorService.csproj
Current Project: C:\Users\Desktop\CalculatorSample\CalculatorService\CalculatorService.csproj

1. [Next step] Back up project
2. Convert project file to SDK style
3. Clean up NuGet package references
    a. Duplicate reference analyzer
    b. Package map reference analyzer
    c. Target compatibility reference analyzer
    d. Upgrade assistant reference analyzer
    e. Windows Compatibility Pack Analyzer
    f. MyDotAnalyzer reference analyzer
    g. Newtonsoft.Json reference analyzer
    h. Windows App SDK package analysis
    i. Transitive reference analyzer
4. Update TFM
5. Update NuGet Packages
    a. Duplicate reference analyzer
    b. Package map reference analyzer
    c. Target compatibility reference analyzer
    d. Upgrade assistant reference analyzer
    e. Windows Compatibility Pack Analyzer
    f. MyDotAnalyzer reference analyzer
    g. Newtonsoft.Json reference analyzer
    h. Windows App SDK package analysis
    i. Transitive reference analyzer
6. Add template files
7. Update WCF service to CoreWCF (Preview)
8. Upgrade app config files
    a. Convert Application Settings
    b. Convert Connection Strings
    c. Disable unsupported configuration sections
9. Update source code
    a. Apply fix for UA0002: Types should be upgraded
    b. Apply fix for UA0012: 'UnsafeDeserialize()' does not exist
    c. Apply fix for UA0014: .NET MAUI projects should not reference Xamarin.Forms namespaces
    d. Apply fix for UA0015: .NET MAUI projects should not reference Xamarin.Essentials namespaces
10. Move to next project

Choose a command:
   1. Apply next step (Back up project)
   2. Skip next step (Back up project)
   3. See more step details
   4. Select different project
   5. Configure logging
   6. Exit

注意

在後文中,除非有重要提示,否則不會明確顯示升級步驟。仍會顯示每個步驟的結果。

建立備份

在此升級 CalculatorService 專案的範例中,您將套用每個步驟。 第一個步驟的「命令 1」,將會備份專案:

[10:25:52 INF] Applying upgrade step Back up project
Please choose a backup path
   1. Use default path [C:\Users\Desktop\CalculatorSample.backup]
   2. Enter custom path

此工具會選擇以目前資料夾命名的預設備份路徑,但會在結尾附加 .backup。 您可以另外選擇自訂路徑作為預設路徑。 完成升級後之各專案的資料夾,會複製至備份資料夾。 在此範例中,CalculatorService 資料夾會在備份步驟期間,從 CalculatorSample\CalculatorService 複製到 CalculatorSample.backup\CalculatorService

[10:25:53 INF] Backing up C:\Users\Desktop\CalculatorSample\CalculatorService to C:\Users\t-simonaliao\OneDrive - Microsoft\Desktop\CalculatorSample.backup\CalculatorService
[10:25:53 INF] Project backed up to C:\Users\Desktop\CalculatorSample.backup\CalculatorService
[10:25:53 INF] Upgrade step Back up project applied successfully
Please press enter to continue...

升級專案檔

專案會從 .NET Framework 專案格式升級為 .NET SDK 專案格式。

[10:25:56 INF] Applying upgrade step Convert project file to SDK style
[10:25:56 INF] Converting project file format with try-convert, version 0.4.0-dev
[10:25:56 INF] Recommending executable TFM net6.0 because the project builds to an executable
C:\Users\Desktop\CalculatorSample\CalculatorService\CalculatorService.csproj contains an App.config file. App.config is replaced by appsettings.json in .NET Core. You will need to delete App.config and migrate to appsettings.json if it's applicable to your project.
[10:25:58 INF] Converting project C:\Users\CalculatorSample\CalculatorService\CalculatorService.csproj to SDK style
[10:25:58 INF] Project file converted successfully! The project may require additional changes to build successfully against the new .NET target.
[10:26:00 INF] Upgrade step Convert project file to SDK style applied successfully

請注意每個步驟的輸出。 請注意,此範例輸出指出,您將在升級之後,手動完成一個步驟:

.NET Core 中的 appsettings.json 會取代 App.config。 若其適用於您的專案,您必須刪除 App.config,並移轉至 appsettings.json。

在此範例中,WCF 更新步驟會依據 App.config 中的 system.serviceModel 區段,建立新的 wcf.config。我們將無須移轉至 appsettings.json。

清除 NuGet 參考

專案格式更新之後,接下來是清除 NuGet 封裝參考。

除了您應用程式參考的封裝之外,packages.config 檔案還包含對這些封裝之相依性的參考。 例如,若您曾新增對封裝 A 的參考,而該封裝相依於封裝 B,則在 packages.config 檔案中,會同時參考這兩個封裝。 在新專案系統中,只需要對封裝 A 的參考。 此步驟會分析封裝參考,並移除不需要的參考。

[10:26:01 INF] Initializing upgrade step Clean up NuGet package references
[10:26:01 INF] Initializing upgrade step Duplicate reference analyzer
[10:26:01 INF] No package updates needed
[10:26:01 INF] Initializing upgrade step Package map reference analyzer
[10:26:01 INF] Marking assembly reference System.configuration for removal based on package mapping configuration System.Configuration
[10:26:01 INF] Adding package System.Configuration.ConfigurationManager based on package mapping configuration System.Configuration
[10:26:01 INF] Marking assembly reference System.ServiceModel for removal based on package mapping configuration System.ServiceModel
[10:26:01 INF] Adding package System.ServiceModel.Primitives based on package mapping configuration System.ServiceModel
[10:26:01 INF] Adding package System.ServiceModel.Http based on package mapping configuration System.ServiceModel
[10:26:01 INF] Adding package System.ServiceModel.Duplex based on package mapping configuration System.ServiceModel
[10:26:01 INF] Adding package System.ServiceModel.NetTcp based on package mapping configuration System.ServiceModel
[10:26:01 INF] Adding package System.ServiceModel.Security based on package mapping configuration System.ServiceModel
[10:26:01 INF] Adding package System.ServiceModel.Federation based on package mapping configuration System.ServiceModel

[10:26:01 INF] Initializing upgrade step Remove reference 'System.configuration'
[10:26:03 INF] Applying upgrade step Remove reference 'System.configuration'
[10:26:03 INF] Removing outdated assembly reference: System.configuration
[10:26:03 INF] Upgrade step Remove reference 'System.configuration' applied successfully

[10:26:05 INF] Initializing upgrade step Remove reference 'System.ServiceModel'
[10:26:06 INF] Applying upgrade step Remove reference 'System.ServiceModel'
[10:26:06 INF] Removing outdated assembly reference: System.ServiceModel
[10:26:06 INF] Upgrade step Remove reference 'System.ServiceModel' applied successfully

[10:26:07 INF] Initializing upgrade step Add package 'System.Configuration.ConfigurationManager'
[10:26:09 INF] Applying upgrade step Add package 'System.Configuration.ConfigurationManager'
[10:26:09 INF] Adding package reference: System.Configuration.ConfigurationManager, Version=5.0.0
[10:26:09 INF] Upgrade step Add package 'System.Configuration.ConfigurationManager' applied successfully
[10:26:09 INF] Applying upgrade step Package map reference analyzer
[10:26:09 INF] Upgrade step Package map reference analyzer applied successfully

[10:26:10 INF] Initializing upgrade step Target compatibility reference analyzer
[10:26:10 INF] No package updates needed
[10:26:10 INF] Initializing upgrade step Upgrade assistant reference analyzer
[10:26:11 INF] Reference to .NET Upgrade Assistant analyzer package (Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, version 0.4.336902) needs to be added
[10:26:11 INF] Initializing upgrade step Add package 'Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers'
[10:26:13 INF] Applying upgrade step Add package 'Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers'
[10:26:13 INF] Adding package reference: Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, Version=0.4.336902
[10:26:13 INF] Upgrade step Add package 'Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers' applied successfully
[10:26:13 INF] Applying upgrade step Upgrade assistant reference analyzer
[10:26:14 INF] Upgrade step Upgrade assistant reference analyzer applied successfully

[10:26:15 INF] Initializing upgrade step Windows Compatibility Pack Analyzer
[10:26:15 INF] No package updates needed
[10:26:15 INF] Initializing upgrade step MyDotAnalyzer reference analyzer
[10:26:15 INF] No package updates needed
[10:26:15 INF] Initializing upgrade step Newtonsoft.Json reference analyzer
[10:26:15 INF] No package updates needed
[10:26:15 INF] Initializing upgrade step Windows App SDK package analysis
[10:26:15 INF] No package updates needed
[10:26:15 INF] Initializing upgrade step Transitive reference analyzer
[10:26:15 INF] No package updates needed
[10:26:15 INF] Applying upgrade step Clean up NuGet package references
[10:26:15 INF] Upgrade step Clean up NuGet package references applied successfully

您的應用程式仍然會參考 .NET Framework 組件。 其中有一些組件可能會以 NuGet 封裝的形態提供。 此步驟會分析這些組件,並參考適當的 NuGet 封裝。

在此範例中,封裝更新程式會將偵測到的 CalculatorService 視為伺服器獨有的專案,因此無須新增 System.ServiceModel 封裝。 即使已經依據封裝對應組態,將這些封裝新增至清單,這些步驟依然不會套用。

處理 TFM

此工具接下來會將 TFM 從 .NET Framework 變更為建議的 SDK。 在此範例中為 net6.0-windows

[10:26:17 INF] Applying upgrade step Update TFM
[10:26:17 INF] Recommending executable TFM net6.0 because the project builds to an executable
[10:26:19 INF] Updated TFM to net6.0
[10:26:19 INF] Upgrade step Update TFM applied successfully

升級 NuGet 封裝

此工具接下來會將專案的 NuGet 封裝,更新為支援更新後之 TFM net6.0-windows 的版本。

[10:26:20 INF] Initializing upgrade step Update NuGet Packages
[10:26:20 INF] Initializing upgrade step Duplicate reference analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step Package map reference analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step Target compatibility reference analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step Upgrade assistant reference analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step Windows Compatibility Pack Analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step MyDotAnalyzer reference analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step Newtonsoft.Json reference analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step Windows App SDK package analysis
[10:26:20 INF] No package updates needed
[10:26:20 INF] Initializing upgrade step Transitive reference analyzer
[10:26:20 INF] No package updates needed
[10:26:20 INF] Applying upgrade step Update NuGet Packages
[10:26:20 INF] Upgrade step Update NuGet Packages applied successfully

新增範本檔案

封裝更新之後,接著要更新範本檔案。 此範例沒有範本檔案需要更新或新增至專案。 此步驟會予以略過,然後下一個步驟會自動啟動。

[10:26:20 INF] Initializing upgrade step Add template files
[10:26:20 INF] 0 expected template items needed

將 WCF 服務更新為 CoreWCF (預覽)

注意:本文件撰寫之時,正提供 WCF 更新程式延伸模組預覽版。 對於此預覽版如有任何意見,可在升級小幫手 GitHub 存放庫中,使用 area:WCF 標籤開立問題。

升級小幫手會先初始化 WCF Updater 步驟,然後確定專案是否適合 WCF 更新。

[10:26:20 INF] Initializing upgrade step Update WCF service to CoreWCF (Preview)
[10:26:20 INF] This config file is applicable for upgrade: C:\Users\Desktop\CalculatorSample\CalculatorService\App.config. System.serviceModel/services elements were found.
[10:26:20 INF] This  file is applicable for upgrade: C:\Users\Desktop\CalculatorSample\CalculatorService\service.cs. ServiceHost object was found.
[10:26:20 INF] This project file is applicable for upgrade: C:\Users\Desktop\CalculatorSample\CalculatorService\CalculatorService.csproj. Reference to System.serviceModel was found.
[10:26:20 INF] This project is applicable for updating to CoreWCF. Initializing the update step...
[10:26:20 INF] Updaters are successfully constructed. Ready to start update.

Choose a command:
   1. Apply next step (Update WCF service to CoreWCF (Preview))
   2. Skip next step (Update WCF service to CoreWCF (Preview))
   3. See more step details
   4. Select different project
   5. Configure logging
   6. Exit

此步驟會個別檢查組態檔、原始程式碼和專案檔,以判斷專案是否適合 WCF 更新。 若專案不適合(例如不使用 WCF,或不符合本文開頭所述的需求),記錄訊息會描述不適合的檔案及缺少的項目。 此步驟會跳過,然後自動啟動下一個步驟。

在此範例中,CalculatorSample 適合 WCF 更新,因此,我們將選擇 [命令 1] 來套用此步驟。

[10:26:23 INF] Applying upgrade step Update WCF service to CoreWCF (Preview)
[10:26:23 INF] Finish updating project file.
[10:26:23 WRN] The mex endpoint is removed from .config file, and service metadata behavior is configured in the source code instead.
[10:26:23 INF] Finish updating configuration files.
[10:26:23 WRN] Changing void Main() to async Task Main() to enable awaiting starting and stopping the ASP.NET Core host.
[10:26:23 INF] Finish updating source code.
[10:26:23 INF] Finish writing changes to project file.
[10:26:23 INF] Finish writing changes to configuration files.
[10:26:23 INF] Finish writing changes to the source code to replace the ServiceHost instance(s).
[10:26:23 INF] Project was successfully updated to use CoreWCF services. Please review changes.
[10:26:23 INF] Upgrade step Update WCF service to CoreWCF (Preview) applied successfully

此步驟會建立更新,並將其個別寫入原始檔案中。 請注意輸出,其可能會通知您升級後,須移除原始檔案或手動更新。

組態和程式碼檔案更新

若此工具判斷您的專案無須任何動作,可能會自動略過這些步驟。

WCF 更新完成之後,接下來是更新應用程式組態檔。 此範例的應用程式組態檔無須升級任何項目。 WCF 步驟已更新了組態檔,因此此步驟對於使用不支援 system.serviceModel 不會有任何負面反應。 此步驟會予以略過,然後下一個步驟會自動啟動。

[10:26:43 INF] Initializing upgrade step Upgrade app config files
[10:26:43 INF] Found 0 app settings for upgrade:
[10:26:43 INF] Found 0 connection strings for upgrade:
[10:26:43 INF] 0 web page namespace imports need upgraded:

完成此專案升級前的最後一個步驟,是更新任何過期的程式碼參考。 此步驟會依據您升級的專案類型,顯示已知之程式碼修正的清單。 有一些修正程式可能不適用於您的專案。

9. Update source code
    a. Apply fix for UA0002: Types should be upgraded
    b. Apply fix for UA0012: 'UnsafeDeserialize()' does not exist
    c. Apply fix for UA0014: .NET MAUI projects should not reference Xamarin.Forms namespaces
    d. Apply fix for UA0015: .NET MAUI projects should not reference Xamarin.Essentials namespaces

在此情況下,將不會對範例專案套用任何建議的修正程式,且此步驟會在上一個步驟完成之後,隨即自動完成。

[10:26:44 INF] Initializing upgrade step Update source code
[10:26:44 INF] Running analyzers on CalculatorService
[10:26:48 INF] Identified 0 diagnostics in project CalculatorService
[10:26:51 INF] Initializing upgrade step Move to next project

完成升級

若有任何其他專案需要移轉,此工具可讓您選取要升級的下一個專案。 若無其他專案需要升級時,此工具會帶您前往 [完成升級] 步驟:

1. [Next step] Finalize upgrade

Choose a command:
   1. Apply next step (Finalize upgrade)
   2. Skip next step (Finalize upgrade)
   3. See more step details
   4. Configure logging
   5. Exit
>
[10:27:15 INF] Applying upgrade step Finalize upgrade
[10:27:15 INF] Upgrade step Finalize upgrade applied successfully

理想而言,若此工具執行成功,這些變更應會出現在原始檔案中。

service.cs 檔案中,對 CoreWCF 的參考會取代 using System.ServiceModelServiceHost 執行個體也會移除,且服務會裝載在 ASP.NET Core 上。

using System;
using System.Threading.Tasks;
using CoreWCF;
using CoreWCF.Configuration;
using CoreWCF.Description;
using CoreWCF.Security;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
    public static async Task Main()
    {
        var builder = WebApplication.CreateBuilder();

        // Set up port (previously this was done in configuration,
        // but CoreWCF requires it be done in code)
        builder.WebHost.UseNetTcp(8090);
        builder.WebHost.ConfigureKestrel(options =>
        {
            options.ListenAnyIP(8080);
        });

        // Add CoreWCF services to the ASP.NET Core app's DI container
        builder.Services.AddServiceModelServices()
                        .AddServiceModelConfigurationManagerFile("wcf.config")
                        .AddServiceModelMetadata()
                        .AddTransient<CalculatorSample.CalculatorService>();

        var app = builder.Build();

        // Enable getting metadata/wsdl
        var serviceMetadataBehavior = app.Services.GetRequiredService<ServiceMetadataBehavior>();
        serviceMetadataBehavior.HttpGetEnabled = true;
        serviceMetadataBehavior.HttpGetUrl = new Uri("http://localhost:8080/CalculatorSample/metadata");

        // Configure CoreWCF endpoints in the ASP.NET Core hosts
        app.UseServiceModel(serviceBuilder =>
        {
            serviceBuilder.AddService<CalculatorSample.CalculatorService>(serviceOptions => 
            {
                serviceOptions.DebugBehavior.IncludeExceptionDetailInFaults = true;
            });

            serviceBuilder.ConfigureServiceHostBase<CalculatorSample.CalculatorService>(serviceHost =>
            {

            });
        });
            
        await app.StartAsync();
        Console.WriteLine("The service is ready.");
        Console.WriteLine("Press <ENTER> to terminate service.");
        Console.WriteLine();
        Console.ReadLine();
        await app.StopAsync();
    }

至於組態檔,App.configsystem.serviceModel 區段會移至更新期間產生的新組態檔 wcf.config 中。

App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- system.serviceModel section is moved to a separate wcf.config file located at the same directory as this file.-->
</configuration>

wcf.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="CalculatorSample.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
        <!--The host element is not supported in configuration in CoreWCF. The port that endpoints listen on is instead configured in the source code.-->
        <!--<host>
  <baseAddresses>
    <add baseAddress="net.tcp://localhost:8090/CalculatorSample/service" />
    <add baseAddress="http://localhost:8080/CalculatorSample/service" />
  </baseAddresses>
</host>-->
        <!-- this endpoint is exposed at the base address provided by host: net.tcp://localhost:8090/CalculatorSample/service  -->
        <endpoint address="/CalculatorSample/service" binding="netTcpBinding" contract="CalculatorSample.ICalculator" />
        <!-- the mex endpoint is exposed at http://localhost:8080/CalculatorSample/service/ -->
        <!--The mex endpoint is removed because it's not support in CoreWCF. Instead, the metadata service is enabled in the source code.-->
      </service>
    </services>
    <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
    <!--The behavior element is not supported in configuration in CoreWCF. Some service behaviors, such as metadata, are configured in the source code.-->
    <!--<behaviors>
  <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
      <serviceMetadata httpGetEnabled="True" />
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>-->
  </system.serviceModel>
</configuration>

最後,在專案檔 CalculatorService.csproj 中,SDK 會更新為 Microsoft.NET.Sdk.Web,以啟用 ASP.NET Core 主機,並會新增 CoreWCF 封裝參考。

  <ItemGroup>
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
    <PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.336902">
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="CoreWCF.NetTcp" Version="1.1.0" />
    <PackageReference Include="CoreWCF.Primitives" Version="1.1.0" />
    <PackageReference Include="CoreWCF.ConfigurationManager" Version="1.1.0" />
    <PackageReference Include="CoreWCF.Http" Version="1.1.0" />
    <PackageReference Include="CoreWCF.WebHttp" Version="1.1.0" />
  </ItemGroup>

請注意,CalculatorSample 中沒有專案對專案的相依性,而且要在更新 CalculatorService 之後,才能成功執行範例。 但在其他具有不同相依性的案例中,您可能也必須更新同一解決方案中的其他專案。

升級之後

當您升級專案之後,必須編譯並測試它們。 升級小幫手會執行其能執行的步驟,但無法在專案升級期間,解決每一項不相容的問題。 例如,應用程式的 .NET Framework 版本可能包含對專案實際上並未使用的程式庫參考。 您必須分析每項參考,判斷其是否需要。 此工具可能也已將 NuGet 套件參考新增或升級至錯誤的版本。

疑難排解秘訣

使用 .NET 升級小幫手時,可能會發生數個已知問題。 在某些情況下,這些問題來自於 .NET 升級小幫手內部使用的 try-convert 工具

此工具的 GitHub 存放庫具有更多疑難排解秘訣和已知問題。

另請參閱