dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.21k stars 1.35k forks source link

Msbuild 15.0 cannot build Coded UI test project from normal command prompt. #2117

Closed acesiddhu closed 7 years ago

acesiddhu commented 7 years ago

With msbuild 15.0 we are seeing that coded ui test projects doesn’t build if we use a normal command prompt. This used to work with msbuild 14.0.

Here is a repro

1) Unzip attached coded ui test zip on local machine CodedUITestProject2.zip

2) Run c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe " CodedUITestProject2.sln" or codeduitestproject.csproj (use normal command prompt and not developer command prompt)

Ideally the project should have been build. We tried same steps with msbuild 14 and it works fine

After investigation we saw that the csproj takes a dependency for “VisualStudioVersion”. We see that this value is null when building with msbuild 15.0. Other point to note is that .sln defines “VisualStudioVersion = 15.0.26228.9”. shouldn’t this just work?

stffabi commented 7 years ago

We are seeing exactly the same problem. Setting VisualStudioVersion property to 15.0 in the msbuild call seems to fix the problem.

It seems like for normal csproj or vbproj projects the VisualStudioVersion get's set through the Microsoft.Common.props. This is normally imported as first project in csproj or vbproj files by: <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

Unfortunately our csproj which contains the codedui test code doesn't have this imported. Also creating a new coded ui project from the "Add Project Wizard" doesn't add this import.

Does someone know if this is a bug in the template für coded ui test projects? Importing the Microsoft.Common.props for coded ui test projects seems to fix the problem. But I have no clue if this breaks something else.

stffabi commented 7 years ago

@rainersigwald do you know if it would be safe to import Microsoft.Common.props for coded ui projects?

acesiddhu commented 7 years ago

@stffabi you can add the import. it wont have any issues.

rainersigwald commented 7 years ago

This is a duplicate of #1678 but has more detailed information, so I'm going to leave both open for now.

rainersigwald commented 7 years ago

Fixed by #2258.

mgolois commented 7 years ago

When will this be released?

rainersigwald commented 7 years ago

@mgolois It's in our master branch, which is targeted at the next "big" update of Visual Studio 2017. No release date has been announced for that yet.

mgolois commented 7 years ago

@rainersigwald any workaround other than using Developer Command Prompt for 2017?

rainersigwald commented 7 years ago

Workarounds

mgolois commented 7 years ago

@rainersigwald Thank you!

mgolois commented 7 years ago

@rainersigwald , sorry, I was able to use the command Prompt VS2017 and the VisualStudioVersion property, but I was unable to import Microsoft.Common.props I put this at the top of my proj file:

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

I got this error:

: error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\4.0\Microsoft.Common.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

reemuluzumaki commented 7 years ago

I am running VS Studio 2015 with MS Build 14.0 . I am successfully building my CodedUI project through MSBuild, but when trying to add my test with TCM so that they can be accessed by MTM, it says 'no tests were found', However when I build the .dll using Visual Studio, TCM can find the Tests. Are there some flags in the build command that are missing?