AArnott / Library.Template

A template for a NuGet package with tests, stylecop, fxcop, versioning, and Azure Pipelines build ready to go.
MIT License
131 stars 26 forks source link

WPF app based on this template fails to compile #22

Closed AArnott closed 4 years ago

AArnott commented 5 years ago

The XAML compiler seems to not like the read only source tree.

As reported by @bretjohnson

AArnott commented 4 years ago

It seems to still be a problem, even for .NET Core WPF projects added to this repo:

1>------ Rebuild All started: Project: WpfApp1, Configuration: Debug Any CPU ------
1>D:\git\lib.template\src\WpfApp1\MainWindow.xaml.cs(23,16,23,26): warning CS1591: Missing XML comment for publicly visible type or member 'MainWindow.MainWindow()'
1>Done building project "WpfApp1_zk3lipur_wpftmp.csproj".
1>D:\git\lib.template\obj\WpfApp1\Debug\netcoreapp3.0\MainWindow.g.cs(58,21,58,38): error CS1504: Source file 'MainWindow.xaml' could not be opened -- Could not find file.
1>D:\git\lib.template\obj\WpfApp1\Debug\netcoreapp3.0\App.g.cs(51,21,51,31): error CS1504: Source file 'App.xaml' could not be opened -- Could not find file.
1>Done building project "WpfApp1.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
AArnott commented 4 years ago

It is the presence of this in Directory.Build.props:

https://github.com/AArnott/Library.Template/blob/ea9aac0dc07b2586d00197699a1de5b8daa69cab/src/Directory.Build.props#L29

That, in combination with redirecting the obj directory does it. Remove either one and it builds successfully.

AArnott commented 4 years ago

I filed a bug against SourceLink: https://github.com/dotnet/sourcelink/issues/492

AArnott commented 4 years ago

Workaround

Add this within a <PropertyGroup> in your WPF project file:

<EmbedUntrackedSources>false</EmbedUntrackedSources>