*.dll.licenses file in obj directory not created w

2019-01-31 17:40发布

问题:

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) generates a file in the obj directory called MyApplication.Web.Mvc.dll.licenses which apparently is required for building, but we have no idea what the file is actually used for.

New MSBuild (v14.0.23107.0) does not create this MyApplication.Web.Mvc.dll.licenses file, so the build fails with the following error:

CSC error CS1566: Error reading resource 'MyApplication.Web.Mvc.dll.licenses' 
-- 'Could not find file 'C:\BuildAgent\work\58ddf5f1234d8c8a\application\MyApplication\MyApplication.Web.Mvc\obj\Release\MyApplication.Web.Mvc.dll.licenses'.' 

I have been running the builds manually via cmd on the machine, and the dll.licenses file gets created whenever running the build using the old msbuild, just not the new one.

The file gets created on the development machines running VS2015, but not on the Teamcity build server. So it seems to me that something else is out of date?

回答1:

After a bit more googling, I stumbled upon this thread on MSDN.

The solution suggested here is to install the Windows 10 SDK. We did this on our TeamCity build server running Windows Server 2012 R2 using the default installation options, and after a reboot, our build was working again.

Hope this helps :)



回答2:

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:

  • July 2015 (Version 10.0.26624.0) contains .NET Framework 4.6 SDK
  • Nov. 2015 (Version 10.0.10586.212) contains .NET Framework 4.6.1 SDK
  • Aug. 2016 (Version 10.0.14393.0) contains .NET Framework 4.6.2 SDK

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.



回答3:

In my case TFS was using the license compiler lc.exe from the older SDK folder

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\lc.exe

instead of

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\LC.exe

This issue was solved by adding the following msbuild argument to the build definition:

/p:FrameworkOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2"

You can also get rid of these issues and make your life easier by installing visual studio on the build server and adding a visual studio build step to replace your 2015 msbuild step



回答4:

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



回答5:

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.



回答6:

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



回答7:

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.

  1. Installed Windows 10 SDK on the build server. In my case, installing the SDK "revealed" the underlying error which is that MSBuild was not generating the *.dll.licenses file.
  2. Added /tv:14.0 ( /ToolsVersion:14.0 ) to my build parameters.

/p:Configuration=Release /p:VisualStudioVersion=14.0 /tv:14.0 /verbosity:Normal

  1. Created the license file manually as a step prior to executing the MSBuild step. The following command creates the file "myproject.dll.licenses".

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"