I am working on upgrading our TeamCity projects from VS2012 to VS2015 and I am running into an issue compiling our MVC application.
Old MSBuild (v4.0.30319.34209) g
We had the same problem when building with VisualBuild. I found a solution without installing the Win10 SDK:
In the projects properties Compile Settings we added a "Pre-build Event Command Line" like this:
pushd "%VS120COMNTOOLS%..\..\VC"
call vcvarsall.bat
popd
pushd $(ProjectDir)\"My Project"
lc /target:$(TargetFileName) /complist:licenses.licx /outdir:"..\obj\$(ConfigurationName)"
popd
popd
This command uses the (older) VS12 Tools and starts the lc compiler tool manually prior to the build of the project and compiles the licenses.licx file into the *.licenses resource file
The answer "Install the Windows 10 SDK" is correct - basically. But there is an additional pitfall: There is more then one version existing of this SDKs: https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
By the writing of this comment:
Check your VS 2015 output and what version of LC.exe is called. Then install the appropriate SDK on the build server. Don't forget to install Microsoft Build Tools 2015 too.
Note: My build is targeting .net 4.5, but above is needed to build on TeamCity with 2015 tools.
Could be helpful for someone:
After installing the Windows 10 SDK and rebooting my server, I've added /p:VisualStudioVersion=14.0 /p:TargetFrameworkVersion=v4.5.2
to my msbuild.exe. That solved it in my case.
In our case we use Atlassian Bamboo as build server with build agents running Windows Server 2012 (not R2). So installing the Windows 10 SDK or Visual Studio Build Tools 2017 or 2019 was not an option because it won't install on Windows Server 2012 because it does not meet system requirements.
I got it working with a pre-build event added to the VS project. (Thanks Joseph Haslinger for the idea)
The pre-build event added to the project properties calls a PowerShell script with the following command:
powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(ProjectDir)pre-build.ps1 $(ProjectDir) $(TargetFileName)
The command is based on the one from Jiří Činčura of tabs ↹ over ␣ ␣ ␣ spaces
I’m setting
ExecutionPolicy
toBypass
in case somebody would not have it set toUnrestricted
.
I'm using Atlassian Bamboo as our build server but otherwise had exactly the same problem described here. I tried every solution in this thread but couldn't get anything to work. In the end, I used the new version of MSBuild that comes with Visual Studio 2017 and suddenly my licence dll was created correctly. In my case, the MSBuild.exe can be found at:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
This is a closely related but slightly different situation in that I am using Jenkins to control the build...
I had to make several changes.
/p:Configuration=Release /p:VisualStudioVersion=14.0 /tv:14.0 /verbosity:Normal
cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools"
.\lc.exe /target:MyProject.dll /complist:"C:\Program Files (x86)\Jenkins\jobs\MyProject\workspace\MyProject\licenses.licx" /i:"C:\Program Files\nsoftware\E-Payment Integrator V6 .NET Edition\lib\nsoftware.InPayWeb.dll" /outdir:"C:\Program Files (x86)\Jenkins\jobs\MyProject\workspace\MyProject\obj\Release"