I have an older codebase that uses an ASP.NET Web Site (not an ASP.NET Web App) and am trying to construct a Pipeline for it on Azure DevOps.
After running into some difficulty when the process reaches aspnet_compiler.exe, I created a simple test solution containing a single ASP.NET Web Forms Site, generated from the template in VS2019. I then created a Pipeline using the ASP.NET template and ran it, which ended in familiar failure. The test solution and the real solution are failing at the same spot, so at least I have pinpointed the problem... unfortunately, I don't know how to address it.
The full log for the build step is at the bottom of my post, but here's where I'm stuck specifically:
Project "D:\a\9\s\Hello.sln" (1) is building "D:\a\9\s\WebSite1_1_.metaproj" (2) on node 1 (default targets).
Build:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_51752 -p WebSite1\ -u -f PrecompiledWeb\localhost_51752\
##[error]WebSite1\web.config(116,0): Error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
D:\a\9\s\WebSite1\web.config(116): error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located. [D:\a\9\s\WebSite1_1_.metaproj]
I should note that this doesn't appear to be related to the Microsoft.CodeDom.Providers.DotNetCompilerPlatform assembly specifically. In my actual ASP.NET Web Site (not this little test one I'm working with here), this same "Error ASPCONFIG: ... * could not be located." error occurs if the site's web.config contains this, for example:
<compilation debug="true" defaultLanguage="c#" targetFramework="4.8">
<assemblies>
<add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
In that case, it will throw the same error, but about Microsoft.Web.Infrastructure instead. Clearly, aspnet_compiler.exe is unable to find my references, but I don't know what's missing -- are the references not being copied somewhere, or is the process not looking for them in the right place, or... ?
Here is the entire Azure DevOps Pipeline build log:
##[section]Starting: Build solution
==============================================================================
Task : Visual Studio build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.166.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "D:\a\9\s\Hello.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=f1e19740-d1c0-4435-a66d-d2b7ccec211f|SolutionDir=D:\a\9\s"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\a\9\a\\" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_ab00089e-3c64-4607-ad03-57473b1db76f_build_3_0"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 8/28/2020 6:48:44 PM.
Project "D:\a\9\s\Hello.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "release|any cpu".
Project "D:\a\9\s\Hello.sln" (1) is building "D:\a\9\s\WebSite1_1_.metaproj" (2) on node 1 (default targets).
Build:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_51752 -p WebSite1\ -u -f PrecompiledWeb\localhost_51752\
##[error]WebSite1\web.config(116,0): Error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
D:\a\9\s\WebSite1\web.config(116): error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located. [D:\a\9\s\WebSite1_1_.metaproj]
Done Building Project "D:\a\9\s\WebSite1_1_.metaproj" (default targets) -- FAILED.
Done Building Project "D:\a\9\s\Hello.sln" (default targets) -- FAILED.
Build FAILED.
"D:\a\9\s\Hello.sln" (default target) (1) ->
"D:\a\9\s\WebSite1_1_.metaproj" (default target) (2) ->
(Build target) ->
D:\a\9\s\WebSite1\web.config(116): error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located. [D:\a\9\s\WebSite1_1_.metaproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:09.47
##[error]Process 'msbuild.exe' exited with code '1'.
##[section]Finishing: Build solution
Web Sites seem to need a little extra love to work in an Azure DevOps Pipeline, but they can work. Here's where I landed...
The Pipeline environment doesn't have Visual Studio installed. Make certain that your *.refresh files are pointing to downloaded packages (i.e. stuff NuGet automatically puts in your packages directory), not to the Visual Studio shared packages directory.
In a new Web Site project, for example, the content of Bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll.refresh defaults to:
..\..\..\Program Files (x86)\Microsoft Visual Studio\Shared\Packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
...but should be:
..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
NuGet has no idea it needs to restore packages for a Web Site because there's no *.csproj to tell it so. Add a custom NuGet restore task (where "WebSite1" is the directory your Web Site is in):
steps:
- task: NuGetCommand#2
displayName: 'NuGet Restore for Web Site'
inputs:
command: custom
arguments: 'restore $(Build.SourcesDirectory)\WebSite1\packages.config -SolutionDirectory $(Build.SourcesDirectory)'
NuGet won't run the install PowerShell script to put all the Roslyn files in your Bin directory prior to running aspnet_compiler.exe. You have to do that yourself with a Copy files task:
steps:
- task: CopyFiles#2
displayName: 'Copy Roslyn files'
inputs:
SourceFolder: '$(Build.SourcesDirectory)\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\RoslynLatest'
TargetFolder: '$(Build.SourcesDirectory)\WebSite1\Bin\roslyn'
Related
We have a Xamarin Forms Project that builds fine in VS20198 but the iOS build fails on the hosted mac in Azure DevOps (ADO)
Looking at this output from ADO build
2019-10-15T17:04:27.5851930Z MTOUCH : error MT2001: Could not link assemblies. Reason: Error while processing references of 'ProjectBreatheApp.iOS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' [/Users/vsts/agent/2.158.0/work/1/s/ProjectBreatheApp/ProjectBreatheApp.iOS/ProjectBreatheApp.iOS.csproj]
2019-10-15T17:04:27.5852990Z --- inner exception
2019-10-15T17:04:27.5899390Z Mono.Linker.LoadException: Error while processing references of 'ProjectBreatheApp.iOS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Linker.LoadException: Error while processing references of 'ProjectBreatheApp.Forms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Linker.LoadException: Error while processing references of 'FreshMvvm, Version=1.0.7010.22624, Culture=neutral, PublicKeyToken=null' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
2019-10-15T17:04:27.5901640Z at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <c00644197a08419abff2c4cf790b9f65>:0
2019-10-15T17:04:27.5903940Z at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00071] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/AssemblyResolver.cs:80
2019-10-15T17:04:27.5904560Z at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00009] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:210
2019-10-15T17:04:27.5906030Z --- End of inner exception stack trace ---
I can see it is failing to find 4.2.0.0 version of STTE. That version does not exist and I don't believe it ever did. How can I tell the build to take a different version?
We are not directly referencing STTE, the library we are using, FreshMVVM that is in the linking stack trace is not referencing it directly and more importantly I do have a working ADO iOS build of a simple XF project that does use that FreshMVVM.
Plenty of other people have had issues with a reference to 4.2.0.0 STTE, they have suggested an explicit reference to the file. I could not get that to work.
I had a similar issue with System.Threading.Tasks.Extensions where my project builded fine locally but not in Azure Pipelines.
The issue is that the agent "macOS-10.14" does not uses by default the latest Mono and Xamarin.iOS SDK.
By switching to the latest XCode (11.1), NetCore 2.x, Mono (6.4) and Xamarin.iOS SDK solved the issue in my case.
Here are the Tasks that I've used to configure my pipeline:
- task: UseDotNet#2
displayName: 'Use .Net Core sdk 2.x'
inputs:
version: 2.x
- bash: |
SYMLINK=6_4_0
MONOPREFIX=/Library/Frameworks/Mono.framework/Versions/$SYMLINK
echo "##vso[task.setvariable variable=DYLD_FALLBACK_LIBRARY_PATH;]$MONOPREFIX/lib:/lib:/usr/lib:$DYLD_LIBRARY_FALLBACK_PATH"
echo "##vso[task.setvariable variable=PKG_CONFIG_PATH;]$MONOPREFIX/lib/pkgconfig:$MONOPREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
echo "##vso[task.setvariable variable=PATH;]$MONOPREFIX/bin:$PATH"
displayName: 'Select Mono Version'
- bash: |
echo "Select Xamarin Version"
/bin/bash -c "sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 6_4_0"
displayName: 'Select Xamarin Version'
- bash: |
echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_11.1.app;sudo xcode-select --switch /Applications/Xcode_11.1.app/Contents/Developer
displayName: 'Select XCode Version'
Hope this helps!
UPDATE
Just for reference here you can find what is installed in each image available in Azure Pipelines and how to select tools according to MS docs
Azure Pipelines Image Generation
How can I manually select versions of tools on the Hosted macOS agent?
In the BizTalk Console Administration I often see exceptions like the following:
There was a failure executing the response(receive) pipeline: "[pipelineName], [BizTalk projectName], Version=1.0.0.0, Culture=neutral, PublicKeyToken=35805574d24305bf" Source: "Unknown " Send Port: "[sendPortName]" URI: "[sqlServerConnString]" Reason: Failed to get pipeline: [pipelineName], [BizTalk projectName], Version=1.0.0.0, Culture=neutral, PublicKeyToken=35805574d24305bf. Please verify that the pipeline strong name is correct and that the pipeline assembly is in the GAC.
I think the problem is how I deployed the pipeline and the project because I have developed my solution on a Virtual Machine (that have Visual Studio) and then I deployed my solution on another Virtual Machine (that does not have Visual Studio installed).
For the deploy I put the dll needed in a folder and then I added them from BizTalk Administration tool (Resources). Another strange thing I noticed is that in Resources I have:
[pipelineName], Version=1.0.0.0, Culture=netrual, PublicKeyToken=60cf10bb1a125a7
[BizTalk projectName], Version=1.0.0.0, Culture=netrual, PublicKeyToken=35805574d24305bf
I have no idea how to solve this issue. Can you help me?
Please check:
pipelineName is a pipeline inside the project (and the DLL)
[BizTalk projectName], Version=1.0.0.0, Culture=netrual, PublicKeyToken=35805574d24305bf
Your DLL have to be in the GAC, please check that the DLL is in the GAC, If not, add the DLL from BizTalk Administration tool (Resources) with "Add to the global assembly cache on add resource (gacutil)" option checked.
On resources you only need this:
[BizTalk projectName], Version=1.0.0.0, Culture=netrual, PublicKeyToken=35805574d24305bf
The other one ([pipelineName], Version=1.0.0.0, Culture=netrual, PublicKeyToken=60cf10bb1a125a7) is another DLL that you added to this BizTalk application.
You have to properly deploy the Pipeline Component Assembly.
This article explains the entire process: BizTalk Server: Deploying Custom Pipeline Components in BizTalk Server 2006 and Higher
I had to restart the associated hosts and the standard BizTalkServerApplication host to refresh the in-memory data.
I have Build Definition
.NET Core Restore
.Net Core Build
.Net Core Test
.Net Core Publish
Publish Artefact
While I was using Core1.1 it worked without any issue. But after upgrading project to Core2.0 it fails with multiple errors like
error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\buildguest\.nuget\packages\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Threading.Tasks.Parallel.dll' and 'C:\Users\buildguest\.nuget\packages\system.threading.tasks.parallel\4.3.0\ref\netstandard1.1\System.Threading.Tasks.Parallel.dll'
error CS0433: The type 'TargetFrameworkAttribute' exists in both 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
error CS0518: Predefined type 'System.String' is not defined or imported
Solution is perfectly building locally. I tried to add task Use .NET Core runtime 2.0.0 in the beginning but without any success.
You should add .NET Core Tool Installer task at the beginning of the build steps. Then install the SDK not only runtime. Then save your build definition and queue again.
When I build my asp.net application in VSTS with aspnetcompilemerge either in an msbuild argument or a publish profile, I get the following error:
MyProject\obj\release\aspnetcompilemerge\source\web.config(129,0): Error ASPCONFIG: The element 'buildProviders' cannot be defined below the application level.
Process 'msbuild.exe' exited with code '1'.
I believe this is in reference to this section of the web.config:
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
</buildProviders>
But two things are odd about this -
1) My internet research on that error message shows issues with deploying or running a website, but I'm not deploying, only building.
2) The build does seem to succeed. I'm able to download the artifact and deploy it to an on prem web server, and the output appears to have been merged as defined in my publish profile.
Any ideas how to resolve this?
EDIT - I was able to reproduce this situation in a new MVC project.
Publish profile:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>MergeAllOutputsToASingleAssembly</WDPMergeOption>
<UseMerge>True</UseMerge>
<SingleAssemblyName>buildprovidertest.PublishedOutput</SingleAssemblyName>
<DeleteAppCodeCompiledFiles>True</DeleteAppCodeCompiledFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\Publish\buildprovidertest</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
I was able to narrow it down to the <MvcBuildViews> node in the csproj file. When that is true, I get this error message. If I set it to false, the build succeeds.
Posting the entire build log exceeds the character limit for stackoverflow, but here's the end:
2017-07-31T13:43:32.4134567Z Adding file (d:\a\1\s\buildprovidertest\obj\Release\Package\PackageTmp\Web.config).
2017-07-31T13:43:32.4134567Z Adding ACL's for path (d:\a\1\s\buildprovidertest\obj\Release\Package\PackageTmp)
2017-07-31T13:43:32.4134567Z Adding ACL's for path (d:\a\1\s\buildprovidertest\obj\Release\Package\PackageTmp)
2017-07-31T13:43:32.4204577Z Adding declared parameter 'IIS Web Application Name'.
2017-07-31T13:43:32.4224576Z Adding declared parameter 'DefaultConnection-Web.config Connection String'.
2017-07-31T13:43:32.4904577Z Successfully executed Web deployment task.
2017-07-31T13:43:32.4984583Z Package "buildprovidertest.zip" is successfully created as single file at the following location:
2017-07-31T13:43:32.4984583Z file:///d:/a/1/a
2017-07-31T13:43:32.4984583Z To get the instructions on how to deploy the web package please visit the following link:
2017-07-31T13:43:32.4984583Z http://go.microsoft.com/fwlink/?LinkId=124618
2017-07-31T13:43:32.5184584Z GenerateSampleDeployScript:
2017-07-31T13:43:32.5184584Z Sample script for deploying this package is generated at the following location:
2017-07-31T13:43:32.5184584Z d:\a\1\a\buildprovidertest.deploy.cmd
2017-07-31T13:43:32.5184584Z For this sample script, you can change the deploy parameters by changing the following file:
2017-07-31T13:43:32.5184584Z d:\a\1\a\buildprovidertest.SetParameters.xml
2017-07-31T13:43:32.5184584Z PipelineDeployPhase:
2017-07-31T13:43:32.5184584Z Publish Pipeline Deploy Phase
2017-07-31T13:43:32.6134809Z CleanupForBuildMvcViews:
2017-07-31T13:43:32.6134809Z Deleting file "obj\Release\TransformWebConfig\assist\Web.config".
snip
2017-07-31T13:43:32.6384579Z Deleting file "obj\Release\Package\PackageTmp\Views\Shared\_LoginPartial.cshtml".
2017-07-31T13:43:32.6384579Z MvcBuildViews:
2017-07-31T13:43:32.6384579Z C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p d:\a\1\s\buildprovidertest
2017-07-31T13:43:37.9922053Z ##[error]buildprovidertest\obj\release\aspnetcompilemerge\source\web.config(21,0): Error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
2017-07-31T13:43:37.9922053Z d:\a\1\s\buildprovidertest\obj\release\aspnetcompilemerge\source\web.config(21): error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. [d:\a\1\s\buildprovidertest\buildprovidertest.csproj]
2017-07-31T13:43:37.9922053Z Done Building Project "d:\a\1\s\buildprovidertest\buildprovidertest.csproj" (default targets) -- FAILED.
2017-07-31T13:43:37.9932061Z Done Building Project "d:\a\1\s\buildprovidertest.sln" (buildprovidertest target(s)) -- FAILED.
2017-07-31T13:43:37.9932061Z
2017-07-31T13:43:37.9932061Z Build FAILED.
2017-07-31T13:43:38.0012046Z
2017-07-31T13:43:38.0012046Z "d:\a\1\s\buildprovidertest.sln" (buildprovidertest target) (1) ->
2017-07-31T13:43:38.0012046Z "d:\a\1\s\buildprovidertest\buildprovidertest.csproj" (default target) (2) ->
2017-07-31T13:43:38.0012046Z (MvcBuildViews target) ->
2017-07-31T13:43:38.0012046Z d:\a\1\s\buildprovidertest\obj\release\aspnetcompilemerge\source\web.config(21): error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. [d:\a\1\s\buildprovidertest\buildprovidertest.csproj]
2017-07-31T13:43:38.0012046Z
2017-07-31T13:43:38.0012046Z 0 Warning(s)
2017-07-31T13:43:38.0012046Z 1 Error(s)
2017-07-31T13:43:38.0012046Z
2017-07-31T13:43:38.0012046Z Time Elapsed 00:00:55.07
2017-07-31T13:43:38.1372049Z ##[error]Process 'msbuild.exe' exited with code '1'.
2017-07-31T13:43:38.1882046Z ##[section]Finishing: Build solution
With that setting, you can’t publish it through VS 2015 too.
Add this code to project file (xx.csproj):
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
<Target Name="AfterBuild">
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
</Target>
Related thread: TeamCity Build Failure
I have a Web API I created in ASP 5 MVC 6 (FULL CLR). The web API references a standard .net class library, which has the entity framework 6 NUGET package installed. If I launch the web api locally (IIS express) and then try to run a method which contacts the database, everything works fine.
When I deploy the web API (I set it up in IIS), using the "Publish" command, to my DEV server (Windows Server 2012) and try to contact the same method, but on the server, I get the following exception (any other method that doesn't touch the database works):
{
"$id":"1",
"ClassName":"System.IO.FileNotFoundException",
"Message":"Could not load file or assembly 'EntityFramework,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
or one of its dependencies. The system cannot find the file specified.",
"Data":null,
"InnerException":null,
"HelpURL":null,
"StackTraceString":"
at CMAllocation.Web.Data.InvestorRulesRepository..ctor()\r\n
at CMAllocation.Web.CMAllocationWebApi.Controllers
.InvestorRulesController.GetInvestors()
in E:\\CMAllocation\\WebServices\\CMAllocationWebApi
\\Debug\\approot\\src\\CMAllocation.Web.CMAllocationWebApi
\\Controllers\\InvestorRulesController.cs:line 45",
"RemoteStackTraceString":null,
"RemoteStackIndex":0,
"ExceptionMethod":
"1\n.ctor\nCMAllocation.Web.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null\nCMAllocation.Web.Data.InvestorRulesRepository\nVoid .ctor()",
"HResult":-2147024894,
"Source":"CMAllocation.Web.Data",
"WatsonBuckets":null,
"FileNotFound_FileName": "EntityFramework, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089",
"FileNotFound_FusionLog":
"WRN: Assembly binding logging is turned OFF.\r\n
To enable assembly bind failure logging, set the registry value
[HKLM\\Software\\Microsoft\\Fusion!EnableLog] (DWORD) to 1.\r\n
Note: There is some performance penalty associated with
assembly bind failure logging.\r\n
To turn this feature off, remove the registry value
[HKLM\\Software\\Microsoft\\Fusion!EnableLog].\r\n"
}
Any help would be appreciated.
UPDATE I can clearly see the EF 6 dll's in the approot/packages folder:
Your server is missing 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
Build on the server with msbuild.
Run NuGet restore. Dave Ebbo has a good article. It is nuget restore from the cmd line.
If that doesn't work, install the EntityFramework package into the GAC on your server.