-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
BuildManager - Building a .vcxproj from a .NET Framework project using the SDK-style #4375
Comments
Can you look at the documentation about using MSBuildLocator? If that doesn't help, please let me know. If it does, I'd appreciate any thoughts you have about how we could have made it easier for you to find. |
Hi @rainersigwald . I'm trying to use the
The project doen't even run. I get this exception:
No binding redirects are specified. Update: As soon as I add If you want, I prepared this sample app on a branch: https://github.com/joaopgrassi/msbuild-cpp-designtime/tree/msbuildlocator. It has more or less my use case, and using the |
Are there calls to MSBuild APIs in |
So I played around with this and made it "work on my machine".. See joaopgrassi/msbuild-cpp-designtime@master...dasMulli:master
|
Thanks, guys for the help, really appreciate it. I didn't know that I wasn't supposed to have anything on my main block. Perhaps we can make that more clear (and state why) in the docs so others can avoid running into this. @dasMulli, I looked at your changes and I applied them on the "msbuildlocator" branch (https://github.com/joaopgrassi/msbuild-cpp-designtime/tree/msbuildlocator). Your fork builds on top of my initial version, which has a lot of extra code to load the tools, find the SDK tools and so on., that I basically copied from that blog post I mentioned initially. Ultimately it would be nice to not to have all that extra stuff. That's why I created the branch @rainersigwald this is my whole
My findings:
So, even if I don't call |
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:
.vcxproj
) -ProjectA
ProjectB
that programmatically buildsProjectA
usingBuildManager
ProjectC
that referencesProjectB
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 theProjectA
and invoke the native code.ProjectB
exists only as a "builder", meaning theMSBuild
code that usesBuildManager
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<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
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-apisFirst 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 theMicrosoft.Build.*
NuGet packages version15.9.20
ProjectC
(the test project) referencesProjectB
, does not have anyMicrosoft.Build.*
dependency but has the binding redirects for them onapp.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"
toToolsVersion="16.0"
on the.vcxproj
and upgrade the NuGet packages? What about binding redirects?Thanks!
The text was updated successfully, but these errors were encountered: