MSBuild-Referenced DLLs not copying to output bin - msbuild

I was a newbie, a little bit knowledge of visual studio, msbuild and scripting.
I was assigned to a task, to create an automation script for building project using MSbuild and the project has three different configuration and I need to build it sequentially because some projects depend on the output dlls of the other configuration, when building the first configuration it succeed but when I reach the second and third configuration it failed. Because reference DLLs were not copied on the ouput bin of selected configuration causing it to missing assembly reference on some projects. And, the thing is I can't edit the projects, it was only for me to view.
Any help on how could I successfully build it.
My script looks like this:
& $msbuild ($master_sln) /t:Clean /p:Configuration=FirstConfiguration /p:Platform="Any CPU"
& $msbuild ($master_sln) /t:Rebuild /p:Configuration=FirstConfiguration /p:Platform="Any CPU"
& $msbuild ($master_sln) /t:Build /p:Configuration="SecondConfiguration" /p:Platform="Any CPU" /p:BuildProjectReferences=false
& $msbuild ($master_sln) /t:Build /p:Configuration="ThirdConfiguration" /p:Platform="Any CPU" /p:BuildProjectReferences=false

Related

How can I change the compiling dir of hlsl files using CMAKE?

I am using CMake 3.9.1, and I am already changing my project RUNTIME_OUTPUT_DIRECTORY to a different folder.
However, I want to change the output of hlsl files(cso).
The following works for CMAKE 3.9.1 visual studio
add_custom_command(TARGET ${projectName} POST_BUILD COMMAND cmd /c ${PROJECT_CONFIGURATION}/shadercopy.bat)
It will run the .bat right after visual studio builds the project and right before it executes!

Is it possible to build cmake projects directly using MSBuildTools

Currently we are planning to use VS2017 with a cmake project. Inside Visual Studio this works quite like a charm.
Now want to run our builds as part of CI on a dedicated build master running MSBuildTools.
Is it possible to directly run the build using the msbuild command, without creating solution files with cmake? Optimally, I would even use the CMakeSettings.json used from VS2017.
Use the build-tool-mode of CMake for this. It uses the underlying default build tool which is MSBuild for Visual Studio Generators.
From the build directory call:
cmake --build . --target ALL_BUILD --config Release -- /nologo /verbosity:minimal /maxcpucount
and you get a fast, nearly quiet build. To install use INSTALL target, for running your tests if configured use RUN_TESTS target.
Is it possible to directly run the build using the msbuild command, without creating solution files with cmake?
Is it possible to directly run the build using the msbuild command, without creating solution files with cmake?
As far as I know, CMake produces Visual Studio Projects and Solutions seamlessly. So you can produce projects/solutions.
The only tricky part is to remember to make any changes in the cmake files, rather than from within Visual Studio.
In particular, each CMake project will create a Visual Studio solution (.sln file), while all of the CMake targets belonging to that CMake project will appear as Visual Studio projects within the corresponding solution.
CMake Visual Studio
project <-> Solution (.sln)
Target <-> Project (.vcxproj)
You can check cmake-and-visual-studio for more details.
Since MSbuild can build both solution files and project files, so you could also call msbuild INSTALL.vcxproj
Is it possible to even use the CMakeSettings.json used in VS2017?
The answer is yes, check the blog for details.
If your CMake project requires additional settings to configure the
CMake cache correctly, you can customize these settings by creating a
CMakeSettings.json file in the same folder with the root
CMakeLists.txt. In this file you can specify as many CMake
configurations as you need – you will be able to switch between them
at any time.
You can create the CMakeSettings.json file by selecting the Project >
Edit Settings > path-to-CMakeLists (configuration-name) menu entry.

How to Build a Visual Studio 2017 VSIX using MSBuild

I'm trying to use MSBuild.exe to build my Visual Studio 2017 based VSIX. I can't just build the solution as I don't want to build other projects in there. I tried using variations of the following command but these do not produce a VSIX file:
C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe" /v:normal /p:Configuration="Release" /p:Platform=AnyCPU /p:DeployExtension=false /target:Build "C:/code/Templates/Source/Boilerplate.Vsix/Boilerplate.Vsix.csproj
The solution was to add the magic /p:VisualStudioVersion=15.0 parameter like so:
C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe /p:Configuration="Release" /p:DeployExtension=false /p:VisualStudioVersion=15.0 "C:/code/Templates/Source/Boilerplate.Vsix/Boilerplate.Vsix.csproj"
go to your configuration manager and deselect the projects you do not want to build. (Right click you solution and chose configuration manager..). You can chose between release and debug in the top left as well.

How to set the `OutDir` in the command link with Mono's xbuild.exe?

I'm trying to build a c# solution in msysgit (Windows) using the same build command that I would with msbuild:
"C:/Windows/Microsoft.NET/Framework/v4.0.30319/msbuild.exe" /p:Configuration=Debug /p:OutDir="c:\projects\proudly\build" "src/Proudly.Identity.sln"
With msbuild, the output of the build goes into my /build folder and all is well. Now, when I run the same command with Mono's xbuild, like this:
"C:/Program Files (x86)/Mono/lib/mono/xbuild/12.0/bin/xbuild.exe" /p:Configuration=Debug /p:OutDir="c:\projects\proudly\build" "src/Proudly.Identity.sln"
...and my the build output goes into the /bin/Debug folder of each project instead of my build folder.
I was under the impression that xbuild can be using just like msbuild. Any clue what I'm doing wrong?

MSBuild cannot build my x86 program

I have a program called A. It produces a file, A.exe. A.exe MUST run as a x86 program, and is thus build as one. A.exe refers to B.dll and C.dll.
B.dll and C.dll is set to build as x86 programs to make them available to A.exe
I am fairly new to this building with msbuild.exe so im still learning. I made a buildfile that uses the msbuild task to build my application (A)'s project (.csproj) file. I can easily build everything from within Visual Studio.
When i build from my msbuild (commandline) i get this error: "An attempt was made to load an assembly with an incorrect format B.exe.
<Target Name="Compile">
<Message Text="Compiling"/>
<ItemGroup>
<myproject Include="A.csproj"/>
</ItemGroup>
<MSBuild Projects="#(myproject)" Properties="Configuration=Release;Platform=x86"/>
</Target>
There is no need to build the dlls as x86. They should be build for any platform. When they are loaded by a .exe built for x86 the JIT compiler will compile them for the target chosen for the .exe (i.e. x86 if the .exe is built for x86).
Can't help you with msbuild though :-)