Ok, so I currently have two projects.
Installer - .NET 4.0
Service - .NET 4.5.2
What I would like is for Installer to be built before the Service project, as the output files are bundled into the Installer output.
The problem i am facing is by default, the solution wants to build the Service project before the Installer.
If I go to Project Dependencies for the solution and add Service as a dependency of Installer. I can then build the solution fine from Visual Studio. However, my problem is when i try and build from the commandline which is a requirement for the build server. I get the following error.
C:\Program Files\dotnet\sdk\2.1.300-preview1-008174\Microsoft.Common.CurrentVersion.targets(1603,5): error : Project 'C:\Users\username\Source\Repos\agents\src\Service\LMS.Service.csproj' targets 'net452'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.0'. [C:\Users\username\Source\Repos\agents\src\Installer\Installer.csproj]
Which I am a bit confused by as I am not referencing the project directly, just adding it as a build dependency.
The command executed is dotnet build "C:/Users/username/Source/Repos/agents/src/LicenseMonitoringSystem.sln"
I have also tried the MSBuild equivalent of the command but still get the same error message.
Just for clarity, i am using the new .csproj format.
Update
MSBuild command
& "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/amd64/MSBuild.exe" /m /v:normal /p:Configuration="Release" /p:Platform="Any CPU" /target:Build "C:/Users/username/Source/Repos/agents/src/LicenseMonitoringSystem.sln"
MSBuild output
"C:\Users\usernames\Source\Repos\agents\src\LicenseMonitoringSystem.sln" (Build target) (1) ->
"C:\Users\username\Source\Repos\agents\src\Installer\Installer.csproj.metaproj" (default target) (8) ->
"C:\Users\username\Source\Repos\agents\src\Installer\Installer.csproj" (default target) (9) ->
(_GetProjectReferenceTargetFrameworkProperties target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1603,5): error : Project
'C:\Users\username\Source\Repos\agents\src\Service\LMS.Service.csproj' targets 'net452'. It cannot be referenced by a project that targets '.NETFramew
ork,Version=v4.0'. [C:\Users\username\Source\Repos\agents\src\Installer\Installer.csproj]