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

EmbedUntrackedSources causes WPF project build to fail when obj folder is redirected #492

Open
AArnott opened this issue Nov 15, 2019 · 2 comments
Labels

Comments

@AArnott
Copy link

AArnott commented Nov 15, 2019

  1. Create new WPF application in Visual Studio 2019 (.NET Core is what I chose)
  2. Create a git repo around the solution.
  3. In the solution directory, drop a Directory.Build.props file with this content to redirect the obj directory to a solution level (for a read only source tree):
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <BaseIntermediateOutputPath>$(MSBuildThisDirectory)\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
  </PropertyGroup>
</Project>

The build succeeds. Now add these elements to the Directory.Build.props file:

  <PropertyGroup>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19554-01" PrivateAssets="All" />
  </ItemGroup>

Then build again.
The build will fail:

1>------ Rebuild All started: Project: WpfApp3, Configuration: Debug Any CPU ------
1>D:\obj\WpfApp3\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:\obj\WpfApp3\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 "WpfApp3.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
@tmat
Copy link
Member

tmat commented Nov 15, 2019

This is a bug in WPF: dotnet/wpf#1718

@AArnott
Copy link
Author

AArnott commented Jul 27, 2022

Actually, this is still reproing for me, even when the 'fix' for dotnet/wpf#1718 is applied (by setting IncludePackageReferencesDuringMarkupCompilation=true). And anyway, that bug seems to focus on the markup compilation, whereas in my repro the markup compilation completes successfully. It's the subsequent csc in the original project that fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants