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

WPF: Adding xmlns with clr-namespace to XAML breaks build with cryptic error message #32

Closed
BrunoJuchli opened this issue Feb 22, 2018 · 6 comments · Fixed by #80
Closed

Comments

@BrunoJuchli
Copy link

BrunoJuchli commented Feb 22, 2018

Dear Oren
Today I tried converting a bare WPF Project, i.E. one that was created by VS 15.5.7 New -> Project -> WPF App (.Net Framework) to the new csproj sdk format. I got stuck with:

1>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(419,45): error MSB4057: The target "CoreCompile" does not exist in the project.

Removing the following line from MainWindow.xaml fixes the build:

xmlns:local="clr-namespace:SdkCsprojWpfSpike"

ATM I'm quite perplexed how this can have any effect on the build outcome, but I'd guess it's about the WPF two-pass build...?!


Notably, (not) having the same line @ App.xaml doesn't matter.


Sample Project

Using your sample project I can reproduce the same issue.
The steps I performed:

1 ./Samples/WpfApplication/MainWindow.xaml

insert the following as Line 8:

xmlns:local="clr-namespace:WpfApplication"

image

2 ./Samples/WpfApplication/WpfApplication.csproj

I've had to change the target framework to net471 - because I don't have net462 installed.

3 Open Csproj & Build

.. and you'll see

1>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(419,45): error MSB4057: The target "CoreCompile" does not exist in the project.


I'd be happy providing a PR for the readme/wiki page to document this, at the least. Any directions for a header, where to place it the document?

@BrunoJuchli
Copy link
Author

Also, adding a User Control (WPF) immediately breaks the build:

image

Same solution. Remove the xmlns:local:

image

@clairernovotny
Copy link
Collaborator

I haven't fully documented this yet as there are some nasty workarounds needed that will be going away soon-ish, I hope.

For now, NuGet Package Explorer is a good example to look at:
https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/blob/master/PackageExplorer/NuGetPackageExplorer.csproj

Note the workarounds at the top and bottom of the file:
https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/blob/master/PackageExplorer/NuGetPackageExplorer.csproj#L3-L7
https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/blob/master/PackageExplorer/NuGetPackageExplorer.csproj#L39-L40

@BrunoJuchli BrunoJuchli changed the title WPF: Adding xmlns:local to a XAML breaks build with cryptic error message WPF: Adding xmlns with clr-namespace to XAML breaks build with cryptic error message Feb 22, 2018
@BrunoJuchli
Copy link
Author

@onovotny
Thanks for the quick answer.
That's a fix for the same issue (NuGet/Home#5894) that the sample project also contains a fix for, though it's slightly different.
I'll see what difference it makes and report back.

Also, out-of-the-box the NuGetPackageExplorer doesn't compile for me. Got a copy of the source code as zip, unpacked, and first was confronted with VS migration dialog + afterwards it didn't compile properly.
Can I ask what version of VS you are using?

Thanks!

@BrunoJuchli
Copy link
Author

BrunoJuchli commented Feb 22, 2018

@onovotny
Thanks again - the lines you referenced in PackageExplorer did fix this issue.
In my case, the significant difference was made by

https://github.com/onovotny/MSBuildSdkExtras/blob/master/Samples/WpfApplication/WpfApplication.csproj#L7
vs
https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/blob/master/PackageExplorer/NuGetPackageExplorer.csproj#L7

@clairernovotny
Copy link
Collaborator

I'm using VS 2017 15.5 for NuGet Package Explorer.

@glennawatson
Copy link
Contributor

I was having the exactly same issue and replacing that line did the trick for me as well.

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

Successfully merging a pull request may close this issue.

3 participants