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

MSBuild 2017 can't find azure sdk targets file #1888

Closed
Robar666 opened this issue Mar 20, 2017 · 4 comments
Closed

MSBuild 2017 can't find azure sdk targets file #1888

Robar666 opened this issue Mar 20, 2017 · 4 comments
Labels

Comments

@Robar666
Copy link

Hi,

I'm not quite sure if this is an Azure SDK related issue or a MSBuild issue, so please just close this issue if it's not MSBuild related.

My build server (TeamCity Professional 10.0.5 (build 42677)) currently can't build my Azure solution (several C# projects and one F# project), because MSBuild tries to find the Microsoft.WindowsAzure.targets in the directory:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Windows Azure Tools\2.9\

But it is actually in the directory:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\[VisualStudioVersion]\MSBuild\Microsoft\VisualStudio\v15.0\Windows Azure Tools\2.9\

[VisualStudioVersion] can have the following values "Community", "Professional" ,"Enterprise"

This issue can be resolved by copying the whole content of the directory, but then I get another error in my F# project:

MSB4057: The target "GetTargetFrameworkProperties" does not exist in the project.

This issue can be resolved by adding the /p:VisualStudioVersion=15.0 flag to the MSBuild task in TeamCity.


So yes everything works for me now, but I felt like I should report this. I don't think replacing all files in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\ is the way to go. The /p:VisualStudioVersion=15.0 flag in TeamCity also feels more like a workaround and not like a solution.

I've already created a question on SO (http://stackoverflow.com/questions/42832371 ), but with now response so far.

@rainersigwald
Copy link
Member

Based on BuildTools in the path in the location that is being searched for, you have the Build Tools for Visual Studio 2017 package installed, as well as a full install of VS. If you have VS installed, you don't need Build Tools.

Is your build script invoking the MSBuild.exe from Build Tools directly? If so, you probably just need to invoke the MSBuild.exe from the VS installation where you checked the Azure box in the installer instead.

If TeamCity is finding that version of MSBuild for you, you might need to uninstall Build Tools so that it can find a more appropriate one.

(The root cause of this issue is that Visual Studio now supports side-by-side installations, for example to allow testing an Update Preview without disrupting your primary installation. But the installations may have had different installer options checked, so they may not be all be able to open or build every project. Here, the Build Tools installation is distinct from the VS installations, and doesn't have the Azure targets installed.)

@Robar666
Copy link
Author

Robar666 commented Mar 20, 2017

Yep you are right, the TeamCity agent seems to start MSBuild from build tools:

/msbuildPath:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\amd64\MSBuild.exe

I probably need to restart my TeamCity agent to find the correct MSBuild version, after i removed build tools.


Is there a way to just install the BuildTools with the Azure and F# targets? Those options are not available during the BuildTools installation, at least I'm not seeing them. This would be nice because otherwise I always have to install a full VS on the TeamCity agents.

@rainersigwald
Copy link
Member

Those options are not available during the BuildTools installation, at least I'm not seeing them.

They're really not there. The first release of this Build Tools installer doesn't have nearly enough checkboxes. Teams at Microsoft are trying to improve that for the future (but filing bugs on individual SDKs would help with that--we the MSBuild team don't know every SDK that delivers targets and can't do all the work ourselves, since it often involves splitting up the SDK VSIX into a "build extension" part relevant to Build Tools and a "UI stuff" part needed for full VS workloads). See for example #1697 for the .NET Core SDK.

For now, the guidance remains that you need to install full VS unless Build Tools works for you already.

I'm going to close this issue since MSBuild itself is working as designed.

@vdevappa
Copy link

If someone comes here looking for the solution to the similar problem for VS 2019, to resolve this, just pass the following argument to the msbuild.exe command line:

/p:VisualStudioVersion=16.0
It will pickup the targets file from the correct folder with this. Also, the path for msbuild.exe with VS 2019 is:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe

@AR-May AR-May added the triaged label Feb 21, 2024
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

4 participants