0

I am creating test automation for my code generation library. I have a test project in C# 7.2. The project compiles with Visual Studio without any issues. My test is updating the code of this project. Then I want the test to compile the project, load the assembly, and verify it works as expected.

I tried both msbuild and csc. Both are complaining that 7.2 is too high for them.

I guess there should be a way to compile the project with devenv, which is already installed and works perfectly via UI.

Is there?

1
  • 1
    A devenv command like this:[devenv SolutionName /Build SolnConfigName /Project ProjName /ProjectConfig ProjConfigName]? Commented Mar 27, 2019 at 6:11

1 Answer 1

3

For C# 7.2 you'll have to use the MSBuild version shipped with VS2017 (Version 15). Assuming that the command line runs on a machine where VS2017 Professional is installed, the correct MSBuild path should be

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe

Any other version of MSBuild should fail to compile C# 7. Specifically, I am building C# 7.2 projects with MSBuild 15.9 and it works.

Edit

You could install MSBuild 15 with the build tools for Visual Studio (see here). I don't know fow sure which version will be installed, but I assume that it'd be the latest. Please note that according to this answer the path will be slightly different.

Sign up to request clarification or add additional context in comments.

1 Comment

Glad I could help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.