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

InvalidProjectFileException during NativeVersionInfo_CreateNativeResourceDll test #294

Closed
japj opened this issue Feb 2, 2019 · 8 comments
Assignees

Comments

@japj
Copy link
Contributor

japj commented Feb 2, 2019

When running the test on the master branch in Visual Studio 2017 15.9.6, I get the following error:

Test FullName:	BuildIntegrationTests.NativeVersionInfo_CreateNativeResourceDll
Test Source:	D:\GitHub\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\BuildIntegrationTests.cs : line 866
Test Outcome:	Failed
Test Duration:	0:00:00,011

Result StackTrace:	
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Execution.ProjectInstance.Initialize(ProjectRootElement xml, IDictionary2 globalProperties, String explicitToolsVersion, String explicitSubToolsetVersion, Int32 visualStudioVersionFromSolution, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext)
   at Microsoft.Build.Execution.ProjectInstance..ctor(ProjectRootElement xml, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection)
   at Microsoft.Build.Execution.ProjectInstance..ctor(ProjectRootElement xml, IDictionary2 globalProperties, String toolsVersion, ProjectCollection projectCollection)
   at MSBuildExtensions.<BuildAsync>d__0.MoveNext() in D:\GitHub\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\MSBuildExtensions.cs:line 23
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
   at BuildIntegrationTests.<BuildAsync>d__60.MoveNext() in D:\GitHub\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\BuildIntegrationTests.cs:line 1009
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
   at BuildIntegrationTests.<NativeVersionInfo_CreateNativeResourceDll>d__55.MoveNext() in D:\GitHub\Nerdbank.GitVersioning\src\NerdBank.GitVersioning.Tests\BuildIntegrationTests.cs:line 870
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Result Message:	Microsoft.Build.Exceptions.InvalidProjectFileException : The tools version "14.0" is unrecognized. Available tools versions are "2.0", "3.5", "4.0".  C:\Users\japj\AppData\Local\Temp\2qfp0css.r3o\projdir\test.vcxproj
Result StandardOutput:	Random seed: 2105343586```

I have installed:
Visual Studio Enterprise 2017 15.9.6 (which I used to run the test) and
Visual Studio Enterprise 2019 16.0.0 Preview 2.1

@japj
Copy link
Contributor Author

japj commented Feb 2, 2019

also, it seems the actual test project C:\Users\japj\AppData\Local\Temp\2qfp0css.r3o\projdir\test.vcxproj is not written to disk during the test (so unclear if there is anything wrong in the generated file)

@AArnott
Copy link
Collaborator

AArnott commented Feb 2, 2019

I haven't figured that out yet. I think there's a VS 2015 dependency or something. @heaths, do you know?

I'm seeing this too (thus we skip this test on Azure Pipelines):
https://github.com/AArnott/Nerdbank.GitVersioning/blob/9af6b90e8a2ec72431902cad014c263b9d7ec7ab/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs#L865

@japj
Copy link
Contributor Author

japj commented Feb 2, 2019

Well, there are Microsoft.Build and Microsoft.Build.Tasks.Core 14.3.0 NuGet PackageReferences
But I though that might be because this also needs to run in VS2015.

@japj
Copy link
Contributor Author

japj commented Feb 2, 2019

ok, after upgrading all NuGet PackageReferences I get the next error (same testcase):

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v140\Toolset.targets(34,5): error MSB8036: The Windows SDK version 10.0.14393.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".

(I enabled detailed MSBuild logging in the testcode to get this output)

So there is an additional dependency in order to be able to run the tests, this is due to the test.vcproj template containing <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>

@heaths
Copy link
Contributor

heaths commented Feb 2, 2019

Unfortunately, targeting the Windows SDK requires targeting a specific version. Currently, the 1809 build (RS5) is in both 15.9 and 16.0 preview, so the projects would need to be updated.

@AArnott, I recommend adding a .vsconfig file with instructions how to use it for 15.9 (have to import it into a new or existing instance). 16.0 will pick that file up from the root automatically.

@japj
Copy link
Contributor Author

japj commented Feb 2, 2019

Just to help me understand, from this project point of view, it doesn't really matter which Windows SDK is used right?
It just needs any Windows SDK in order for it to work as it is only interested in being able to verify that the build integration generates the correct build versioning output files.
It is not using the actual exe/dll output from the C++ project as part of the unit test.

@japj
Copy link
Contributor Author

japj commented Feb 2, 2019

does https://github.com/japj/Nerdbank.GitVersioning/commit/f374ba5bd400ab53de08b5211367800a73ef5dac seem like an acceptable solution for not hardcoding the WindowsTargetPlatformVersion?

This uses the same registry mechanism as C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.WindowsSDK.props

@AArnott
Copy link
Collaborator

AArnott commented Feb 2, 2019

Thanks for your tips, @heaths.

That looks great to me, @japj. Can you combine that with re-enabling the test in Azure Pipelines (by removing the attribute) and your other package ref updates that are required, and send a PR?

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

No branches or pull requests

3 participants