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

Build fails claiming a missing win8 target where none exists nor should need to #115

Closed
AArnott opened this issue Sep 6, 2018 · 3 comments
Labels

Comments

@AArnott
Copy link
Collaborator

AArnott commented Sep 6, 2018

From @AArnott on September 6, 2018 15:0

From @AArnott on September 6, 2018 4:11

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): msbuild.exe /restore

MSBuild version: 15.9.10.28431

dotnet.exe --version (if appropriate): 2.1.500-preview-009266

VS version (if appropriate): 15.9.0 preview 2.0 (28029.51.d15.9)

OS version (i.e. win10 v1607 (14393.321)): 17134.rs4_release.180410-1804

Worked before? If so, with which NuGet version: Not sure.

Detailed repro steps so we can see the same problem

git clone https://github.com/AArnott/pinvoke.git
cd pinvoke\src
git checkout a07ddf382cd43853985b07c75a5edda0ad3374f7
msbuild ole32 /t:restore 
msbuild ole32 # add /p:targetframework=win8 for faster repro

Expected

A successful restore and build.

Actual

Restore emits no warnings. Build fails with:

C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error : Assets file 'D:\git\pinvoke\obj\Windows.Core\project.assets.json' doesn't have a target for 'Windows,Version=v8.0'. Ensure that restore has run and that you have included 'win8' in the TargetFrameworks for your project. [D:\git\pinvoke\src\Windows.Core\Windows.Core.csproj]
C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error : Assets file 'D:\git\pinvoke\obj\CodeGenerationAttributes\project.assets.json' doesn't have a target for 'Windows,Version=v8.0'. Ensure that restore has run and that you have included 'win8' in the TargetFrameworks for your project. [D:\git\pinvoke\src\CodeGenerationAttributes\CodeGenerationAttributes.csproj]

Trying to build again (without another restore step) usually succeeds (but not always). Considering the error is allegedly generated from the Windows.Core.csproj and CodeGenerationAttributes.csproj projects, building them individually might presumably fail, but they don't. They only fail when in the context of the larger build.

I claim this is a nuget/msbuild failure because while it is true that the two mentioned projects do not define a win8 target, they shouldn't need to, since they include netstandard1.1 as one of their targets, which per this table should work for any win8 targeted project that references these projects. Also since the failure is inconsistent (a second or third build attempt usually succeeds), it seems like some race condition perhaps during the multi-proc build. Or maybe incremental build is buggy and skips the previously failed build step.

Copied from original issue: NuGet/Home#7277

Copied from original issue: dotnet/sdk#2517

@AArnott
Copy link
Collaborator Author

AArnott commented Sep 6, 2018

In studying the build logs using the MSBuild Structured Log Viewer (and the /bl build switch) I found that the fault seems to lie with the GetPackagingOutputs target. It seems this target is defined as empty at one point in the preprocessed project file, but later the AppX .targets are imported and define it to actually something that apparently isn't multitargeting aware and thus doesn't suppress the propagation of the TargetFramework global property.

@AArnott
Copy link
Collaborator Author

AArnott commented Sep 6, 2018

Since it seems that the GetPackagingOutputs target is always supposed to be blank for .NET SDK projects, and seeing I don't have any AppX packaging in my solution, I applied the following workaround:

In my Directory.Build.targets file:

  <!-- Workaround win8 .targets defining a target that should be blank (https://github.com/dotnet/sdk/issues/2517) -->
  <Target Name="GetPackagingOutputs" />

@AArnott
Copy link
Collaborator Author

AArnott commented Sep 6, 2018

Moving to MSBuild.Sdk.Extras because the .NET SDK doesn't even support the win8 target natively.

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