Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression for WPF projects in 2.0.24 #158

Closed
airbreather opened this issue Apr 3, 2019 · 11 comments
Closed

Regression for WPF projects in 2.0.24 #158

airbreather opened this issue Apr 3, 2019 · 11 comments

Comments

@airbreather
Copy link

Using Visual Studio 2019 RTM, .NET Core SDK 2.2.202.

WPF applications / libraries no longer build with the newly released 2.0.24.

I'm pretty sure this is because this line forces ExtrasUseWindowsDesktopApp to be true unconditionally when we opt-in to WPF stuff, even though true is exactly the value that turns off pretty much all the WPF setup that Extras does.

Here's a more-or-less minimal repro, note what happens when switching 1.6.68 to 2.0.24:

WpfApp.csproj

<Project Sdk="MSBuild.Sdk.Extras/1.6.68">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net472</TargetFramework>
    <ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
  </PropertyGroup>

</Project>

App.xaml

<Application x:Class="WpfApp1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml" />

MainWindow.xaml

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="An Extra Special Title"
        Height="450"
        Width="800">
    <TextBlock HorizontalAlignment="Center"
               VerticalAlignment="Center"
               Text="Hello Extras!" />
</Window>

The error I get:
error CS5001: Program does not contain a static 'Main' method suitable for an entry point

@airbreather
Copy link
Author

With a less minimal repro, we get things like:

error CS1061: 'App' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent' accepting a first argument of type 'App' could be found (are you missing a using directive or an assembly reference?)

And so on...

@clairernovotny
Copy link
Collaborator

Can you share a binlog? compile with /binlog?

That line does not control things, it simply removes a FrameworkReference.

The decision on wether to use the .NET Core 3 version of the targets vs the built-in one is here:

https://github.com/onovotny/MSBuildSdkExtras/blob/master/Source/MSBuild.Sdk.Extras/Sdk/Sdk.props#L23

@airbreather
Copy link
Author

WpfApp1.zip includes msbuild.binlog, built from the below command-line:

C:\Projects\Generic\WpfApp1>msbuild WpfApp1.sln /t:Restore;Build /bl
Microsoft (R) Build Engine version 16.0.461+g6ff56ef63c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Apps\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe /bl /t:Restore;Build WpfApp1.sln
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 4/3/2019 12:02:14 PM.
Project "C:\Projects\Generic\WpfApp1\WpfApp1.sln" on node 1 (Restore;Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "C:\Projects\Generic\WpfApp1\WpfApp1.sln" (1) is building "C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (2) on node 1 (_IsProjectRestoreSupported target(s)).
C:\Users\jamenta\.nuget\packages\msbuild.sdk.extras\2.0.24\Build\ExtrasShim.targets(49,5): warning : The property 'ExtrasEnableWpfProjectSetup' is deprecated and will be removed in the future. Please use 'UseWpf'
 instead. [C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj]
Done Building Project "C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (_IsProjectRestoreSupported target(s)).

Restore:
  Restoring packages for C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj...
  Committing restore...
  Generating MSBuild file C:\Projects\Generic\WpfApp1\WpfApp1\obj\WpfApp1.csproj.nuget.g.props.
  Generating MSBuild file C:\Projects\Generic\WpfApp1\WpfApp1\obj\WpfApp1.csproj.nuget.g.targets.
  Writing assets file to disk. Path: C:\Projects\Generic\WpfApp1\WpfApp1\obj\project.assets.json
  Restore completed in 235.55 ms for C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj.

  NuGet Config files used:
      C:\Users\jamenta\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Project "C:\Projects\Generic\WpfApp1\WpfApp1.sln" (1) is building "C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (2:6) on node 1 (default targets).
C:\Users\jamenta\.nuget\packages\msbuild.sdk.extras\2.0.24\Build\ExtrasShim.targets(49,5): warning : The property 'ExtrasEnableWpfProjectSetup' is deprecated and will be removed in the future. Please use 'UseWpf'
 instead. [C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj]
PrepareForBuild:
  Creating directory "bin\Debug\net472\".
  Creating directory "obj\Debug\net472\".
GenerateBindingRedirects:
  No suggested binding redirects from ResolveAssemblyReferences.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Apps\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /nostdlib+ /platform:AnyCPU /errorreport:prompt /warn:4 /define:TRACE;
  DEBUG;NETFRAMEWORK;NET472 /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\M
  icrosoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /reference:"C:\Program Files (x86)\Refe
  rence Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll" /reference:"C:\Program
  Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\S
  ystem.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Mic
  rosoft\Framework\.NETFramework\v4.7.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" /debug+ /debug:portable /filealign:512
   /optimize- /out:obj\Debug\net472\WpfApp1.exe /ruleset:"C:\Apps\Microsoft Visual Studio\2019\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /targe
  t:winexe /warnaserror- /utf8output /deterministic+ obj\Debug\net472\WpfApp1.AssemblyInfo.cs /warnaserror+:NU1605
  Using shared compilation with compiler from directory: C:\Apps\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj]
Done Building Project "C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (default targets) -- FAILED.

Done Building Project "C:\Projects\Generic\WpfApp1\WpfApp1.sln" (Restore;Build target(s)) -- FAILED.

Deferred Messages

  Detailed Build Summary
  ======================


  ============================== Build Hierarchy (IDs represent configurations) =====================================================
  Id                  : Exclusive Time   Total Time   Path (Targets)
  -----------------------------------------------------------------------------------------------------------------------------------
  0                   : 0.835s           1.935s       C:\Projects\Generic\WpfApp1\WpfApp1.sln (Restore, Build)
  | 1                 : 0.389s           0.389s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_IsProjectRestoreSupported)
  | 2                 : 0.012s           0.012s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_GenerateRestoreProjectPathWalk)
  | 3                 : 0.058s           0.058s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_GenerateRestoreGraphProjectEntry)
  | 4                 : 0.025s           0.025s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_GenerateProjectRestoreGraph)
  . 5                 : 0.614s           0.614s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj ()

  ============================== Node Utilization (IDs represent configurations) ====================================================
  Timestamp:            1        Duration   Cumulative
  -----------------------------------------------------------------------------------------------------------------------------------
  636899041347281249:   0        0.308s     0.308s ######
  636899041350361274:   1        0.389s     0.697s #######
  636899041354251302:   0        0.018s     0.715s
  636899041354431292:   2        0.012s     0.727s
  636899041354551285:   0        0.005s     0.732s
  636899041354601293:   3        0.058s     0.791s #
  636899041355186270:   0        0.002s     0.792s
  636899041355201288:   4        0.025s     0.817s
  636899041355451288:   0        0.503s     1.320s ##########
  636899041360476335:   5        0.614s     1.933s ############
  636899041366611433:   0        0.006s     1.940s
  -----------------------------------------------------------------------------------------------------------------------------------
  Utilization:          100.0    Average Utilization: 100.0

Build FAILED.

"C:\Projects\Generic\WpfApp1\WpfApp1.sln" (Restore;Build target) (1) ->
"C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (_IsProjectRestoreSupported target) (2) ->
(_WarnWhenUsingObsoleteProperties target) ->
  C:\Users\jamenta\.nuget\packages\msbuild.sdk.extras\2.0.24\Build\ExtrasShim.targets(49,5): warning : The property 'ExtrasEnableWpfProjectSetup' is deprecated and will be removed in the future. Please use 'UseWp
f' instead. [C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj]


"C:\Projects\Generic\WpfApp1\WpfApp1.sln" (Restore;Build target) (1) ->
"C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (default target) (2:6) ->
  C:\Users\jamenta\.nuget\packages\msbuild.sdk.extras\2.0.24\Build\ExtrasShim.targets(49,5): warning : The property 'ExtrasEnableWpfProjectSetup' is deprecated and will be removed in the future. Please use 'UseWp
f' instead. [C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj]


"C:\Projects\Generic\WpfApp1\WpfApp1.sln" (Restore;Build target) (1) ->
"C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (default target) (2:6) ->
(CoreCompile target) ->
  CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj]

    2 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.39

@airbreather
Copy link
Author

For completeness, here it is on success with 1.6.68: WpfApp1.zip

C:\Projects\Generic\WpfApp1>msbuild WpfApp1.sln /t:Restore;Build /bl
Microsoft (R) Build Engine version 16.0.461+g6ff56ef63c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Apps\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe /bl /t:Restore;Build WpfApp1.sln
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 4/3/2019 12:12:16 PM.
Project "C:\Projects\Generic\WpfApp1\WpfApp1.sln" on node 1 (Restore;Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Restore:
  Restoring packages for C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj...
  Committing restore...
  Generating MSBuild file C:\Projects\Generic\WpfApp1\WpfApp1\obj\WpfApp1.csproj.nuget.g.props.
  Generating MSBuild file C:\Projects\Generic\WpfApp1\WpfApp1\obj\WpfApp1.csproj.nuget.g.targets.
  Writing assets file to disk. Path: C:\Projects\Generic\WpfApp1\WpfApp1\obj\project.assets.json
  Restore completed in 279.33 ms for C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj.

  NuGet Config files used:
      C:\Users\jamenta\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Project "C:\Projects\Generic\WpfApp1\WpfApp1.sln" (1) is building "C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (2:6) on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin\Debug\net472\".
  Creating directory "obj\Debug\net472\".
GenerateBindingRedirects:
  No suggested binding redirects from ResolveAssemblyReferences.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Apps\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /nostdlib+ /platform:AnyCPU /errorreport:prompt /warn:4 /define:TRACE;
  DEBUG;NETFRAMEWORK;NET472 /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\M
  icrosoft\Framework\.NETFramework\v4.7.2\PresentationCore.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\PresentationFramework.dll" /reference:"C:\Program F
  iles (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /refer
  ence:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Dra
  wing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft
  \Framework\.NETFramework\v4.7.2\System.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" /reference:"C:\Program Fil
  es (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xaml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.dll" /referenc
  e:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Wind
  owsBase.dll" /debug+ /debug:portable /filealign:512 /optimize- /out:obj\Debug\net472\WpfApp1.exe /ruleset:"C:\Apps\Microsoft Visual Studio\2019\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets\MinimumReco
  mmendedRules.ruleset" /subsystemversion:6.00 /resource:obj\Debug\net472\WpfApp1.g.resources /target:winexe /warnaserror- /utf8output /deterministic+ C:\Projects\Generic\WpfApp1\WpfApp1\obj\Debug\net472\MainWind
  ow.g.cs C:\Projects\Generic\WpfApp1\WpfApp1\obj\Debug\net472\App.g.cs "C:\Projects\Temp\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" obj\Debug\net472\WpfApp1.AssemblyInfo.cs /warnaserror+:NU1605
  Using shared compilation with compiler from directory: C:\Apps\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn
_CopyAppConfigFile:
  Copying file from "C:\Projects\Generic\WpfApp1\WpfApp1\obj\Debug\net472\WpfApp1.exe.withSupportedRuntime.config" to "C:\Projects\Generic\WpfApp1\WpfApp1\bin\Debug\net472\WpfApp1.exe.config".
CopyFilesToOutputDirectory:
  Copying file from "C:\Projects\Generic\WpfApp1\WpfApp1\obj\Debug\net472\WpfApp1.exe" to "C:\Projects\Generic\WpfApp1\WpfApp1\bin\Debug\net472\WpfApp1.exe".
  WpfApp1 -> C:\Projects\Generic\WpfApp1\WpfApp1\bin\Debug\net472\WpfApp1.exe
  Copying file from "C:\Projects\Generic\WpfApp1\WpfApp1\obj\Debug\net472\WpfApp1.pdb" to "C:\Projects\Generic\WpfApp1\WpfApp1\bin\Debug\net472\WpfApp1.pdb".
Done Building Project "C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj" (default targets).

Done Building Project "C:\Projects\Generic\WpfApp1\WpfApp1.sln" (Restore;Build target(s)).

Deferred Messages

  Detailed Build Summary
  ======================


  ============================== Build Hierarchy (IDs represent configurations) =====================================================
  Id                  : Exclusive Time   Total Time   Path (Targets)
  -----------------------------------------------------------------------------------------------------------------------------------
  0                   : 0.859s           6.234s       C:\Projects\Generic\WpfApp1\WpfApp1.sln (Restore, Build)
  | 1                 : 0.393s           0.393s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_IsProjectRestoreSupported)
  | 2                 : 0.012s           0.012s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_GenerateRestoreProjectPathWalk)
  | 3                 : 0.052s           0.052s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_GenerateRestoreGraphProjectEntry)
  | 4                 : 0.026s           0.026s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj (_GenerateProjectRestoreGraph)
  . 5                 : 4.890s           4.890s       C:\Projects\Generic\WpfApp1\WpfApp1\WpfApp1.csproj ()

  ============================== Node Utilization (IDs represent configurations) ====================================================
  Timestamp:            1        Duration   Cumulative
  -----------------------------------------------------------------------------------------------------------------------------------
  636899047364569885:   0        0.295s     0.295s #####
  636899047367519676:   1        0.393s     0.688s #######
  636899047371449480:   0        0.017s     0.705s
  636899047371619329:   2        0.012s     0.717s
  636899047371739367:   0        0.005s     0.721s
  636899047371784369:   3        0.052s     0.773s #
  636899047372304737:   0        0.001s     0.775s
  636899047372319378:   4        0.026s     0.801s
  636899047372579329:   0        0.545s     1.345s ##########
  636899047378024365:   5        4.890s     6.236s #################################################################################################
  636899047426925466:   0        0.005s     6.240s
  -----------------------------------------------------------------------------------------------------------------------------------
  Utilization:          100.0    Average Utilization: 100.0

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:06.69

@clairernovotny
Copy link
Collaborator

clairernovotny commented Apr 3, 2019

Thanks. I'll have a look and see what broke as this scenario is supposed to work.

As a workaround/better-scenario anyway, I'd suggest installing the .NET Core 3 SDK (currently at preview 3, https://dotnet.microsoft.com/download/dotnet-core/3.0) and adding a global.json like this:

{
  "sdk": {
    "version": "3.0.100-preview3"
  },
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "2.0.24"
  }
}

This will use the updated targets/tasks in the Core 3 SDK for building (you can still target .NET 4.x) and will unblock you.

@airbreather
Copy link
Author

airbreather commented Apr 3, 2019

FWIW, commenting-out the line that I linked in my local .nuget cache of that file is enough to make the minimal repro (and, indeed, our full application) build and run just fine.

As a workaround/better-scenario anyway, I'd suggest installing the .NET Core 3 SDK (currently at preview 3, https://dotnet.microsoft.com/download/dotnet-core/3.0) and adding a global.json like this:

Thanks -- I've been waiting until General Availability to try it out because even GA releases have been a bit on the bumpy side.

@clairernovotny
Copy link
Collaborator

Thanks -- I've been waiting until General Availability to try it out because even GA releases have been a bit on the bumpy side.

If you use the Visual Studio stable channel, it won't automatically pickup & use preview SDK's by default. It'll default to the latest stable one. That's why you need the global.json, to tell it to use the preview sdk.

The visual studio preview channel will use preview sdk's by default.

@Danielku15
Copy link

I made a manual patch for our projects via a Directory.Build.targets containing:

  <ItemGroup Condition=" '$(UseWpf)' == 'true' AND '$(VisualStudioVersion)' == '16.0'">
      <None Remove="**\*.xaml" />
      <Page Remove="**\*.xaml" />
      <Page Include="**\*.xaml">
          <Generator>MSBuild:Compile</Generator>
      </Page>
      <Page Remove="**\App.xaml" />
      <ApplicationDefinition Include="**\App.xaml" />
      <Reference Include="System.Xaml" />
  </ItemGroup>

It seems VS2019 has some fixes in place regarding the xaml -> cs generation that are now handled wrong/duplicated in the MSBuildSdkExtras compared to VS2017 where it was working fine. For us this works fine even if it might not be 100% correct for all setups. I hope this helps others until a real fix can be provided.

@willson556
Copy link

Thanks. I'll have a look and see what broke as this scenario is supposed to work.

As a workaround/better-scenario anyway, I'd suggest installing the .NET Core 3 SDK (currently at preview 3, https://dotnet.microsoft.com/download/dotnet-core/3.0) and adding a global.json like this:

{
  "sdk": {
    "version": "3.0.100-preview3"
  },
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "2.0.24"
  }
}

This will use the updated targets/tasks in the Core 3 SDK for building (you can still target .NET 4.x) and will unblock you.

Is there any workaround for this issue that will allow some developers to adopt VS2019 and some to stay on VS2017? Some of us would like to test out VS2019 without forcing the whole team to move.

@haefele
Copy link

haefele commented May 13, 2019

Is there any workaround for this issue that will allow some developers to adopt VS2019 and some to stay on VS2017? Some of us would like to test out VS2019 without forcing the whole team to move.

The solution from Danielku15 worked for me.

In the global.json upgrade to MSBuild.Sdk.Extras version 2.0.24

{
  "sdk": {
    "version": "2.2.104"
  },
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "2.0.24"
  }
}

Now we gotta make some adjustments to the csproj file.

Change ExtrasEnableWpfProjectSetup to UseWpf and also set ExtrasEnableImplicitWpfReferences to false (I had errors that the WPF assemblies were not referenced)

<PropertyGroup>
  <UseWpf>true</UseWpf>
  <ExtrasEnableImplicitWpfReferences>false</ExtrasEnableImplicitWpfReferences>
</PropertyGroup>  

Next step, add the WPF assembly references:

<ItemGroup>
  <Reference Include="PresentationCore" />
  <Reference Include="PresentationFramework" />
  <Reference Include="System.Xaml" />
  <Reference Include="WindowsBase" />
</ItemGroup>

And then, add Danielku15's fix (but without the Condition for the VisualStudioVersion)

<ItemGroup Condition=" '$(UseWpf)' == 'true' ">
    <None Remove="**\*.xaml" />
    <Page Remove="**\*.xaml" />
    <Page Include="**\*.xaml">
        <Generator>MSBuild:Compile</Generator>
    </Page>
    <Page Remove="**\App.xaml" />
    <ApplicationDefinition Include="**\App.xaml">
      <Generator>MSBuild:Compile</Generator>
    </ApplicationDefinition>
</ItemGroup>

Now my application builds fine in VS2017 and VS2019 😄

@clairernovotny
Copy link
Collaborator

Closing due to age. If there's a concrete issue that needs to be addressed in VS 2019 with the .NET Core 3 sdk, please reopen.

clairernovotny pushed a commit that referenced this issue Sep 19, 2019
Fix WPF Regression #158 when .net-core 3.0 preview is not installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants