Ivan G.
Ivan G.

Reputation: 5215

three-step visual studio build

My VS 2010 solution has let's say 1 native C++ dll project and 1 c# wrapper project. What I want is a pure magic. My solution has 32 and 64 bit configurations, mostly because of native dll. I'd like to build the solution so that c# dll includes both 32bit and 64bit native dll as resources in c# dll. Then I will unpack proper bitness in runtime and use it (this is not a problem). My question is how do I configure VS solution to build both bitnesses and then put them into the C# project before it builds?

I could probably do a clever .msbuild script, but then I won't be able to build nicely from VS.

Upvotes: 1

Views: 155

Answers (1)

vharavy
vharavy

Reputation: 4981

You can do the following:

  1. Right-click on the C# project in Solution Explorer and select Unload Project.
  2. The project will be unloaded. Right-click on the project again and select Edit *.csproj.
  3. Now you can edit the project file inside Visual Studio. *.csproj file has rather simple XML format.
  4. Go down the *.csproj file right before </Project> closing tag.
  5. Add the following lines:
    <Target Name="BeforeBuild">
        <MSBuild Projects=".\..\NativeLibrary.sln" Properties="Configuration=Release;Platform=x64"/>
        <MSBuild Projects=".\..\NativeLibrary.sln" Properties="Configuration=Release;Platform=Win32"/>
    </Target>

No, you can right-click on the project file in Solution Explorer and select Reload Project.

Also, you will need to add 32-bit and 64-bit *.dll files to resources. I have used this approach for a long time and it works perfectly. You can build your C# project from inside Visual Studio.

Upvotes: 1

Related Questions