BuildManager - Building a .vcxproj from a .NET Framework project using the SDK-style
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
This is more of a question as I'm more or less lost and couldn't find much online. I'll try to describe what I have and want to achieve: Currently, I have a solution with:
- A C++ project (`.vcxproj`) - `ProjectA`
- A .NET Framework class library `ProjectB` that programmatically builds `ProjectA` using `BuildManager`
- A NET Framework MSTest Project - `ProjectC` that references `ProjectB` and run tests.
The C++ project is more or less a "template" project that creates artifacts that simulate IoT devices. It offers APIs so we can "emulate" a physical device. During tests (`ProjectC`) we build multiple versions of the `ProjectA` and invoke the native code. `ProjectB` exists only as a "builder", meaning the `MSBuild` code that uses `BuildManager` lives there.
Both .NET Projects referenced the `Microsoft.Build.*` from the GAC:
```
```
And in `app.config` we had the usual binding redirects:
```
```
After I migrated them to the "new" SDK-style, I couldn't reference them anymore from the GAC, so I installed the NuGet Packages on `ProjectB`, which is the one that uses it:
```
```
I also went ahead and deleted the `app.config` since, (I assumed) the binding redirects were being generated. I have the `true` set on both of them. But, when I ran the tests, I ran on several issues. I pretty much had the same issues as described in this blog post: https://daveaglick.com/posts/running-a-design-time-build-with-msbuild-apis
First I got `The tools version "15.0" is unrecognized. Available tools versions are "12.0", "14.0", "2.0", "3.5", "4.0".` and then I pretty much did what Dave did on the blog post, but still ran into many other issues. At one point I just gave up.
Next day, after sleeping over it, I started again from scratch - I migrated again the test project to the new SDK-style, this time using this handy tool: https://github.com/hvanbakel/CsprojToVs2017 and this time I left the binding redirects there, on `app.config`. Now, I have:
- `ProjectB` references the `Microsoft.Build.*` NuGet packages version `15.9.20`
- `ProjectC` (the test project) references `ProjectB`, does not have any `Microsoft.Build.*` dependency but has the binding redirects for them on `app.config`.
Both projects have these binding redirects:
```
```
I ran the tests and everything works again.. and I'm confused. Which msbuild is being used now? The one from Visual Studio installation, or the one from the NuGet packages? I'm somewhat lost and not sure if this is the correct way of doing it. Seems a bit strange to have these binding redirects or is it just my stupidity?
Also: We use VS 2017 today but.. we want to upgrade to 2019. What would be the way to do that? Just change the `ToolsVersion="15.0"` to `ToolsVersion="16.0"` on the `.vcxproj` and upgrade the NuGet packages? What about binding redirects?
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.