Is there a way in MSBuild logic to determine if I am running managed vs unmanaged code? Not C++ vs C#, but just managed vs unmanaged? I'd like to set some properties (usually just version information) differently depending on whether the code is managed or unmanaged.
相关问题
- Visual Studio 2019 - error MSB8020: The build tool
- Interface from a C DLL to .NET
- Is It possible to build asp.net core project using
- Delete files older 6 months
- msbuild: build as to a appxbundle (AppxBundle=Alwa
相关文章
- Passing struct from unmanaged C++ to C#
- Build errors of missing packages in Visual Studio
- Copy different file to output directory for releas
- Why doesn't AutogenerateBindingRedirects work
- MSBuild - How to build multiple files AND projects
- Visual Studio Solution — Any way to create a “spec
- Invalid value for the configfile paramter of the g
- How is it that a struct containing ValueTuple can
There are normally two things that change in a vcxproj file for managed complation (afaik, at least that's how we have it in our master c++/cli property sheet used for all cli projects: the
CLRSupport
property is set to true and theClCompile
ItemGroup has theCompileAsManaged
metadata set to true. You can check on any of these or both. Here's a target which prints the values:As you can see getting the
CompileAsManaged
metadata value requires some treatment: I'm adding an item to the ClCompile group because if the group is empty you canot use CompileAsManaged; normally you can just omit this.In C++, each item in ClCompile (list of source files) has a
CompileAsManaged
metadata value. Setting properties is difficult since it can vary for each source file, but is more straightforward if you only expect (and support) keying off the whole-project setting. Toggle that in the IDE and see what changes in the vcxproj file. It has a few different values to choose from.