Change WebApi Application Output Directory Assembly

I am part of a team working on a large application. I am a new addition to this team and am creating a new part of the application. As part of this process, I created a WebApi application that will output some HTTP endpoints through which I will receive information about the application.

Due to conditions that would take too long to explain, I would like the WebApi project to be created in another directory, in particular ..\bin\Server\Debug\ , since this is the majority of other parts of the application built. I would not bother, except that the application tried to use files found based on the working directory, which is currently not suitable for my WebApi application.

I tried changing it in the project settings and now I get this error: Could not load type WebApiApplication

My googling has not helped much so far. Does anyone know how to solve this?

+9
c # iis asp.net-web-api
Apr 24 '15 at 16:21
source share
3 answers

Try adding a test path to your runtime configuration:

 <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="bin\server\Debug;"/> </assemblyBinding> </runtime> </configuration> 

In addition to the above step, and get rid of the globa.asax error. Open the mark of the Global.asax file and add a line to the top line.

 <%@ Assembly Name="<you_web_app_assembly_name_here>" %> 

Now you will begin to receive a System.web or BindingProvider error that is not found, etc. There's a weird fix for starting adding assemblies to an assembly tag when compiling.

  <compilation debug="true" targetFramework="4.5" optimizeCompilations="false"> <assemblies> <add assembly="Microsoft.AspNet.Identity.Core, Version=2.2.1, PublicKeyToken=31bf3856ad364e35" /> <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </assemblies> </compilation> 

You will have a few more errors like this, but that will help you.

Reason . The problem I see is that it is possible to change the output path, but Asp.net does the compilation on the fly. Why is the error related to compilation when trying to start a website. Somewhere, run time compilation can only be viewed in the \bin , and so we must specify each assembly referenced by the project.

Update - Unfortunately, you cannot change the bin directory. After looking through all the options and searching, you find that the bin folder of the Asp.net web project is not a regular binary output folder. This is a shared folder where links to binary files are specified directly in the project.

The binaries are compiled when the first request is received by the web server for the Asp.net application. The bin folder is used only as a shared binary links folder, not the actual output folder / folder. The actual On-the-fly compilation output folder in Asp.net is set to %SystemRoot%\Microsoft.NET\Framework\<versionNumber>\Temporary ASP.NET Files by default, which you can change from the compilation tag attribute [tempDirectory][3] in web.config .

After all this research, I came to the conclusion that the option to change the directory from project -> properties -> Build -> Bin appears because of the Asp.net website project template. This gives the user the same look as any other project. But the functionality of the asp.net website remains the same. The bin folder still works the way it was used to work in the old Asp.net website template.

+5
Oct 22 '15 at 20:26
source share

You can try to copy the dll with the target after the build. First, change the output path to what it was if you changed it earlier. Then add this code to the project file.

 <target name="AfterBuild"> <copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).dll" /> <copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).pdb" /> <copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).xml" /> </target> 

This will put the built-in dll in the folder specified in the destination folder. I usually use this for class libraries, but I don't understand why this will not work for the web api project

You can check out my blog post if you want.

http://torontoprogrammers.blogspot.com/2014/11/msbuild-targets-and-tasks.html

0
Oct 29 '15 at 18:47
source share

You cannot change the output directory of an asp.net application due to IIS security restrictions, so it does not work.

If you are trying to manage the DLL due to DI, copy all other satellite dlls to the bin folder of your asp.net main application

0
Nov 05 '15 at 17:34
source share



All Articles