.NET 6'da CoreWCF kullanmak için WCF Sunucu Tarafı Projesini yükseltme

Önemli

Bu makale, Visual Studio için Yükseltme Yardımcısı uzantısının yayımlanmasından önce yazılmıştır ve eski CLI aracını kullanır. Daha fazla bilgi için bkz . Eski .NET Yükseltme Yardımcısı'nı kullanma.

.NET Yükseltme Yardımcısı, .NET Framework'te var olan bir WCF Sunucu tarafı projesini .NET 6 üzerinde CoreWCF hizmetlerini kullanacak şekilde yükseltmeye yardımcı olabilecek bir komut satırı aracıdır. Bu makalede aşağıdakiler sunulmaktadır:

  • Başlamadan önce bilinmesi gerekenler.
  • .NET Framework'te WCF Sunucu tarafı projesinde aracın nasıl çalıştırıldığında gösterildi.
  • Sorun giderme ipuçları.

Aracın nasıl yükleneceği hakkında daha fazla bilgi için bkz . Eski .NET Yükseltme Yardımcısı'nı kullanma.

Başlamadan önce bilinmesi gerekenler

Bu araç şu anda C# projelerini destekler ve şirket içinde barındırılan WCF Sunucu tarafı projelerini .NET 6'ya getirmek için CoreWCF kullanır.

Bir WCF projesinin bu yükseltme için geçerli olması için aşağıdaki gereksinimleri karşılaması gerekir:

  1. Yeni ServiceHostöğesine başvuran System.ServiceModel ve oluşturan bir .cs dosyası içerir.

    WCF projesinde birden çok ServiceHostvarsa, tüm konakların aynı yöntemde oluşturulması gerekir.

  2. Özellikleri depolayan System.ServiceModel bir .config dosyası içerir.

Aracın geçerli sürümü .svc dosyaları aracılığıyla barındırılan WCF projelerini desteklemiyor.

Not

Projeniz bu araç için geçerli değilse CoreWCF kılavuz kılavuzuna ve BeanTrader Örnek tanıtımına göz atıp projeyi el ile güncelleştirmenizi öneririz.

Tanıtım uygulaması

Yükseltme Yardımcısıyla yükseltmeyi test etmek için Temel Hesap Makinesi Örnek projesini kullanabilirsiniz. Bu da bu belgelerde kullanılan tanıtımdır.

Daha karmaşık bir örnek denemek istiyorsanız Mike Rousos tarafından oluşturulan BeanTrader örneğine bakın.

Upgrade-assistant'ı çalıştırma

Bir terminal açın ve hedef projenin veya çözümün bulunduğu klasöre gidin. upgrade-assistant upgrade Yükselttiğiniz projenin veya çözümün adını geçirerek komutunu çalıştırın.

Bir proje sağlandığında, yükseltme işlemi bu projede hemen başlar. Bir çözüm sağlanırsa, yükseltme giriş noktası olarak bilinen normalde hangi projeyi çalıştırdığınızı seçersiniz. Bu projeye bağlı olarak bir bağımlılık grafiği oluşturulur ve projeleri hangi sırayla yükseltmeniz gerektiği konusunda bir öneri sağlanır.

upgrade-assistant upgrade .\CalculatorSample.sln

Araç çalışır ve gerçekleştireceği adımların listesini gösterir. Her adım tamamlandıktan sonra araç, kullanıcının bir sonraki adımı veya aşağıdakiler gibi başka bir seçeneği uygulamasına veya atmasına olanak sağlayan bir komut kümesi sağlar:

  • Adım hakkında daha fazla bilgi edinin.
  • Projeleri değiştirme.
  • Günlük ayarlarını yapın.
  • Yükseltmeyi durdurun ve çıkın.

Sayı seçmeden Enter tuşuna basıldığında listedeki ilk öğe seçilir.

Her adım başlatılırken, adımı uygularsanız ne olacağını düşündüğü hakkında bilgi sağlayabilir.

Yükseltecek giriş noktasını ve projeyi seçin

Temel Hesap Makinesi Örneği'ni yükseltmenin ilk adımı, çözümdeki hangi projenin giriş noktası projesi olarak görev üstlendiği seçmektir.

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

Bu adımı başlatmak için 1. komutu seçin. Sonuçlar görüntülenir:

[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

Listelenen iki proje vardır. Aracımız sunucu tarafı projesini yükseltdiğinden, giriş noktası olarak hizmet projesini seçmek için komut 2'yi seçeceğiz.

Projeyi yükseltme

Bir proje seçildikten sonra, aracın uygulayacağı yükseltme adımlarının listesi listelenir.

Önemli

Yükseltmekte olduğunuz projeye bağlı olarak, bu örnekte listelenen her adımı görebilir veya göremeyebilirsiniz.

Aşağıdaki çıkışta, projeyi yükseltmeyle ilgili adımlar açıklanmaktadır:

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

Not

Bu makalenin geri kalanında yükseltme adımları, çağrılacak önemli bir şey olmadığı sürece açıkça gösterilmez. Her adımın sonuçları yine de gösterilir.

Yedekleme oluşturma

CalculatorService projesini yükseltmeye ilişkin bu örnekte her adımı uygulayacaksınız. İlk adım olan 1. komut, projeyi yedeklemektir:

[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

Araç, geçerli klasörden sonra adlı ancak .backup sonuna eklenmiş varsayılan bir yedekleme yolu seçer. Varsayılan yola alternatif olarak özel bir yol seçebilirsiniz. Yükseltilen her proje için, projenin klasörü yedekleme klasörüne kopyalanır. Bu örnekte, CalculatorService yedekleme adımı sırasında klasör CalculatorSample\CalculatorService dosyasından CalculatorSample.backup\CalculatorService klasörüne kopyalanır:

[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...

Proje dosyasını yükseltme

Proje ,NET Framework proje biçiminden .NET SDK proje biçimine yükseltilir.

[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

Her adımın çıkışına dikkat edin. Örnek çıktının, yükseltmeden sonra el ile tamamlamanız gereken bir adım olduğunu gösterdiğine dikkat edin:

App.config, .NET Core'da appsettings.json ile değiştirilir. Projeniz için geçerliyse App.config dosyasını silmeniz ve appsettings.json geçiş yapmanız gerekir.

Bu örnekte, WCF güncelleştirme adımı App.config içindeki bölüme göre system.serviceModel yeni bir wcf.config oluşturur. appsettings.json geçiş yapmamız gerekmez.

NuGet başvurularını temizleme

Proje biçimi güncelleştirildikten sonra, sonraki adım NuGet paket başvurularını temizlemektir.

Uygulamanız tarafından başvuruda bulunılan paketlere ek olarak packages.config dosyası bu paketlerin bağımlılıklarına başvurular içerir. Örneğin, B paketine bağlı olan A paketine başvuru eklediyseniz, her iki pakete de packages.config dosyasında başvurabilirsiniz. Yeni proje sisteminde yalnızca A paketi başvurusu gereklidir. Bu adım, paket başvurularını analiz eder ve gerekli olmayanları kaldırır.

[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

Uygulamanız hala .NET Framework derlemelerine başvuruyor. Bu derlemelerden bazıları NuGet paketleri olarak kullanılabilir. Bu adım bu derlemeleri analiz eder ve uygun NuGet paketine başvurur.

Bu örnekte, paket güncelleştirici CalculatorService'i yalnızca sunucu projesi olarak algılar ve paket eklemeye System.ServiceModel gerek yoktur. Paket eşleme yapılandırmasına göre listeye eklenmiş olsalar da, bu adımlar uygulanmamıştır.

TFM'yi işleme

Araç daha sonra TFM'yi .NET Framework'ten önerilen SDK'ya değiştirir. Bu örnekte, şeklindedir 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 paketlerini yükseltme

Ardından araç, projenin NuGet paketlerini güncelleştirilmiş TFM'yi net6.0-windowsdestekleyen sürümlere güncelleştirir.

[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

Şablon dosyaları ekleme

Paketler güncelleştirildikten sonra, sonraki adım şablon dosyalarını güncelleştirmektir. Bu örnekte, güncelleştirililmesi veya projeye eklenmesi gereken şablon dosyası yoktur. Bu adım atlanır ve sonraki adım otomatik olarak başlatılır.

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

WCF hizmetini CoreWCF'ye güncelleştirme (Önizleme)

Not: Bu belge yazıldığı sırada WCF güncelleştirici uzantısı Önizleme sürümü olarak sağlanır. Önizleme sürümüyle ilgili geri bildiriminiz varsa lütfen Yükseltme Yardımcısı GitHub deposunda etiketli area:WCF bir sorun açın.

Yükseltme yardımcısı önce WCF Güncelleştiricisi adımını başlatır ve projenin WCF güncelleştirmesi için uygun olup olmadığını denetler.

[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

Adım, projenin WCF güncelleştirmesi için geçerli olup olmadığını belirlemek için yapılandırma dosyasını, kaynak kodunu ve proje dosyasını ayrı ayrı denetler. Proje geçerli değilse (WCF kullanmama veya makalenin başında belirtilen gereksinimleri karşılamaması gibi), günlük iletisi hangi dosyanın geçerli olmadığını ve neyin eksik olduğunu açıklar. Ardından, adım atlanır ve sonraki adım otomatik olarak başlatılır.

Bu örnekte CalculatorSample WCF güncelleştirmesi için geçerlidir ve adımı uygulamak için komut 1'i seçeceğiz.

[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

Bu adım güncelleştirmeleri oluşturur ve özgün dosyalara ayrı ayrı yazar. Yükseltmeden sonra tamamlanması için özgün dosyalardan kaldırma veya el ile güncelleştirmeler hakkında sizi bilgilendirebilecek çıkışa dikkat edin.

Yapılandırma ve kod dosyaları güncelleştirmesi

Araç projeniz için yapılacak bir şey olmadığını belirlerse bu adımlar araç tarafından otomatik olarak atlanabilir.

WCF güncelleştirmesi tamamlandıktan sonra, bir sonraki adım uygulama yapılandırma dosyalarını güncelleştirmektir. Bu örnekte, uygulama yapılandırma dosyalarında yükseltilmesi gereken bir şey yoktur. WCF adımı, yapılandırma dosyalarını zaten güncelleştirdiğinden system.serviceModel, bu adım desteklenmeyen kullanımından şikayetçi olmaz. Bu adım atlanır ve sonraki adım otomatik olarak başlatılır.

[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:

Bu projenin yükseltmesi tamamlanmadan önceki son adım, güncel olmayan kod başvurularını güncelleştirmektir. Yükseltmekte olduğunuz projenin türüne bağlı olarak, bu adım için bilinen kod düzeltmelerinin listesi görüntülenir. Düzeltmelerden bazıları projeniz için geçerli olmayabilir.

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

Bu durumda, önerilen düzeltmelerin hiçbiri örnek proje için geçerli değildir ve bu adım önceki adım tamamlandıktan hemen sonra otomatik olarak tamamlanır.

[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

Yükseltme tamamlanıyor

Geçirilebilecek başka proje varsa, araç sonraki yükseltme projelerini seçmenize olanak tanır. Yükseltecek başka proje olmadığında, araç sizi "Yükseltmeyi sonlandır" adımına getirir:

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

İdeal olarak, aracı başarıyla çalıştırdıktan sonra bu değişikliklerin özgün dosyalarda görünmesi gerekir.

dosyasında service.cs , using System.ServiceModel CoreWCF başvurularıyla değiştirildi. Örnek ServiceHost de kaldırıldı ve hizmet ASP.NET Core'da barındırıldı.

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();
    }

Yapılandırma dosyaları için içindeki bölümüApp.config, system.serviceModel güncelleştirme sırasında oluşturulan yeni yapılandırma dosyasına wcf.configtaşındı.

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>

Son olarak proje dosyasında SDK, CalculatorService.csprojASP.NET Core konağı ve CoreWCF paket başvuruları eklenecek şekilde güncelleştirildi Microsoft.NET.Sdk.Web .

  <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'da projeden projeye bağımlılığı olmadığına ve örneğin yalnızca CalculatorService güncelleştirildikten sonra başarıyla çalıştırılabildiğine dikkat edin. Ancak farklı bağımlılıklara sahip diğer durumlarda, aynı çözümdeki diğer projeleri de güncelleştirmeniz gerekebilir.

Yükseltmeden sonra

Projelerinizi yükselttikte derlemeniz ve test etmeniz gerekir. Yükseltme yardımcısı yapabileceklerini yapar, ancak proje yükseltmesinin bir parçası olarak her uyumsuzluğu çözemez. Örneğin, uygulamanızın .NET Framework sürümünde projenizin aslında kullanmamış olduğu kitaplık başvuruları bulunabilir. Her başvuruda analiz yapmanız ve gerekli olup olmadığını belirlemeniz gerekir. Araç, nuget paket başvurularını da yanlış sürüme eklemiş veya yükseltmiş olabilir.

Sorun giderme ipuçları

.NET Yükseltme Yardımcısı kullanılırken karşılaşabileceğiniz bilinen birkaç sorun vardır. Bazı durumlarda, bu sorunlar .NET Yükseltme Yardımcısı'nın dahili olarak kullandığı try-convert aracıyla ilgilidir.

Aracın GitHub deposunda daha fazla sorun giderme ipucu ve bilinen sorunlar vardır.

Ayrıca bkz.