Winforms: Contribution guide: explain how to debug changes in the project

Created on 15 Dec 2020  路  12Comments  路  Source: dotnet/winforms

  • .NET Core Version: .net 5.0.101

Problem description:

I am trying to follow the contribution guide, and the debugging guide.

The guide is not clear enough about the different steps required to debug the assemblies from this project.

I have changed some code and want to try them in a new, empty, winform project using the 2nd method of the debugging guide.

I have created a blank .net winform project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5-windows</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="[...]\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll" />
  </ItemGroup>

</Project>

When I try to compile the project using Visual Studio, I receive multiple errors about assemblies versions and conflicts:

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: Found conflicts between different versions of "System.Runtime" that could not be resolved.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: There was a conflict between "System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     "System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.dll].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.Primitives.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.Primitives.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\Accessibility.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\Accessibility.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: Found conflicts between different versions of "System.Runtime.InteropServices" that could not be resolved.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: There was a conflict between "System.Runtime.InteropServices, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime.InteropServices, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     "System.Runtime.InteropServices, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime.InteropServices, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Runtime.InteropServices, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.InteropServices.dll].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.InteropServices.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.InteropServices.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.InteropServices.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Runtime.InteropServices, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.Primitives.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.Primitives.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\Accessibility.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\Accessibility.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: Found conflicts between different versions of "System.ComponentModel.TypeConverter" that could not be resolved.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: There was a conflict between "System.ComponentModel.TypeConverter, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.ComponentModel.TypeConverter, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     "System.ComponentModel.TypeConverter, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.ComponentModel.TypeConverter, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.ComponentModel.TypeConverter, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.ComponentModel.TypeConverter.dll].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.ComponentModel.TypeConverter.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.ComponentModel.TypeConverter.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.ComponentModel.TypeConverter.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.ComponentModel.TypeConverter, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.Primitives.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.Primitives.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
...
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: Found conflicts between different versions of "System.Text.Encoding.CodePages" that could not be resolved.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: There was a conflict between "System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Text.Encoding.CodePages, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     "System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Text.Encoding.CodePages, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Text.Encoding.CodePages.dll].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Text.Encoding.CodePages.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Text.Encoding.CodePages.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Text.Encoding.CodePages.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Text.Encoding.CodePages, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: Found conflicts between different versions of "System.Console" that could not be resolved.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: There was a conflict between "System.Console, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Console, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     "System.Console, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Console, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Console, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Console.dll].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Console.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Console.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Console.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Console, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\code\Tests\WindowsFormsApp12\Form1.cs(13,34,13,38): error CS1705: Assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089' uses 'System.ComponentModel.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.ComponentModel.Primitives' with identity 'System.ComponentModel.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
1>CSC : error CS1705: Assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089' uses 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
1>C:\code\Tests\WindowsFormsApp12\Form1.Designer.cs(9,17,9,23): error CS1705: Assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089' uses 'System.ComponentModel.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.ComponentModel.Primitives' with identity 'System.ComponentModel.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Expected behavior:

The debugging guide should be more precise about how to setup a blank winforms project to debug changes made to the core libraries, using either VS or VSCode.

I suppose I should use a preview SDK to be able to compile the project, or create a custom global.json.

question

All 12 comments

The conflict is due to an outdated .NET SDK 6.0 which is available at dotnet/installer. There have been few breaking changes in the runtime, and unless you have them locally you can't really test the canary builds. Our team and testers have exactly the same problem.
The installer currently is blocked by https://github.com/dotnet/sdk/pull/14574#issuecomment-742024930, and once it is resolved the local testing should work again.

There's a workaround to base your changes not at the latest master but few commits before it. @vladimir-krestov can you point which commit works?

Thank you for your answer. Maybe we could keep this issue open to track when local testing will be available again? Anyway, I will try to use a previous commit.

To test your changes, please rebase your branch to the following last worked commit:
Message: "Loc checkin (#4332)"
Date: 12/7/2020 11:17:14 PM
Commit hash: 80c8cb469ae42b1e8aae1eb7e4c5328d09581b84

@vladimir-krestov thanks I am now able to compile the project with the following csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5-windows</TargetFramework>
    <!--<UseWindowsForms>true</UseWindowsForms>-->
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll" />
  </ItemGroup>

</Project>

But the app crash at runtime with the following error:

Exception thrown: 'System.IO.FileNotFoundException' in System.Windows.Forms.dll
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll
Could not load file or assembly 'System.Drawing.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Le fichier sp茅cifi茅 est introuvable.

I tried enabling UseWindowsForms but received the following error:

1>You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: Found conflicts between different versions of "System.Windows.Forms.Primitives" that could not be resolved.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277: There was a conflict between "System.Windows.Forms.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Windows.Forms.Primitives, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     "System.Windows.Forms.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "System.Windows.Forms.Primitives, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089" was not.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Windows.Forms.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\5.0.0\ref\net5.0\System.Windows.Forms.Primitives.dll].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\5.0.0\ref\net5.0\System.Windows.Forms.Primitives.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\5.0.0\ref\net5.0\System.Windows.Forms.Primitives.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\5.0.0\ref\net5.0\System.Windows.Forms.Primitives.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:     References which depend on "System.Windows.Forms.Primitives, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089" [].
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:         C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:           Project file item includes which caused reference "C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2157,5): warning MSB3277:             C:\code\perso\dotnet\winforms\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0\System.Windows.Forms.dll
1>C:\code\Tests\WindowsFormsApp12\Form1.cs(13,34,13,38): error CS1705: Assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089' uses 'System.Windows.Forms.Primitives, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089' which has a higher version than referenced assembly 'System.Windows.Forms.Primitives' with identity 'System.Windows.Forms.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
1>C:\code\Tests\WindowsFormsApp12\Form1.Designer.cs(9,17,9,23): error CS1705: Assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089' uses 'System.Windows.Forms.Primitives, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089' which has a higher version than referenced assembly 'System.Windows.Forms.Primitives' with identity 'System.Windows.Forms.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

@tbolon, here are all steps:

  • clone the Winforms repository
  • run the start-vs.cmd script to update dependencies and run VisualStudio
  • make your changes in the Winforms project in your branch
  • rebase the branch to the described commit above (80c8cb4)
  • build/rebuild the solution

Don't try to just add a reference to System.Windows.Forms.dll, it doesn't work for me. I don't know why, I use another way described below. - (the first way in the debugging guide)

Next, please, try to do the following steps:

  • go to C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.0-alpha.1.20606.6 or maybe a different version (e.g. 5.0)
  • save copies of System.Windows.Forms.dll and System.Windows.Forms.Primitives.dll files in some different folder for a backup
  • find in [Winforms clone repos root]\artifacts\bin\System.Windows.Forms\Debug\netcoreapp5.0 folder 2 files:
    System.Windows.Forms.dll
    System.Windows.Forms.Primitives.dll
  • make sure that these 2 files are fresh
  • close all processes that use dotnet resources (VS, your app, "NET Core", etc.)
  • copy these 2 files and paste to C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.0-alpha.1.20606.6 folder and replace exist files
  • run your project and try to run your app

I think, the main points here are:

  • use the first way
  • copy System.Windows.Forms.Primitives.dll too

@tbolon, please, let me know when you are able to launch your application with new changes.

Also, the best way how to test your changes is using internal UI test apps.
Look at the WinformsControlsTest project in the repos. Here you can find some forms with test cases. Just copy your application code to some UI case form and run WinformsControlsTest. This is a way of temporary UI testing

Yes it worked. I was able to start my app and debug my source code. Also as soon as I started replacing the assemblies, the VS designer did not work anymore.

Because I modified the public api (overriding OnEnabledChanged), I also copied ref assemblies.

I have now reverted back to a clean SDK and started editing WinformsControlsTest to test my changes, without the designer (which I don't need for simple tests).

I am now trying to implement a RenderingTest to check current border color of my DateTimePicker.

Perhaps if the second way is never intended to work anymore, you could update the documentation to only preserve the first way and write the same detailed steps you have done here ?

Also, perhaps it should be suggested to use WinformsControlsTest without the designer as an alternative to quickly test changes.

Sure, you are right, we will do it after our priority tasks 馃槉

I will try to help if I can, submit a PR after I have understood how these EMF tests works 馃ぃ

Thanks, it would be great!
@RussKie, please add a couple of words about EMF.

FYI I opened a new PR #4374 for my fix, with a render test case.

Needless to say, if you think something is missing or confusing in the docs - feel free to tweak, and send a PR :)

Was this page helpful?
0 / 5 - 0 ratings