I'm having a problem with a web application where the events in the global.asax class aren't being executed when I build the application through our build server and publish the website. In Application_Start is a single line of code sets up our logging, and in Application_Error I have some error handling code. Locally it all works fine, and if I copy the files directly from my development folder to the server rather than publishing it via the build server everything works fine.
From loads of Googling it would appear that this is a problem with the precompiledapp.config file being missing - sure enough it doesn't exist anywhere. However, nowhere can I find out how I actually get the TFS Build Server, or Visual Studio (2010), to create this file so that I can publish it.
Any advice on how I can generate this file would be much appreciated.
EDIT: A bit more information. I've just tried publishing the website through Visual Studio 2010 rather than the build server and this created the precompiledapp.config file. I copied all the files across to the server (except web.config which I left intact) and it logs successfully (which suggests the global.ascx events are being fired). What I need to do now is try and get the build server to do the same thing - any ideas?
Make sure your custom config file is set as a content file and Copy To Output is set to Always in the config file properties in Visual Studio.
I seem to have resolved this issue now.
As I mentioned in the Edit of my original message, when I published the website through Visual Studio 2010 to a local folder it created the Precompiledapp.config file, and copying the folder contents to the test version of the application got everything working. As I can't seem to get the TFS Build server to create this file, I decided to try just copying the file from my local publish folder to the test application, along with the rest of the files from the tfs build, and everything seems to be working as it should.
So although I've not managed to figure out how to get the build server to generate this file, my main issue is resolved and I'm able to use the global.asax file again.
I'm late to this question BUT you should probably verify that you have the correct SDK that visual studio would use to build the precompiled app (I think it's Azure SDK even if not doing anything with Azure but not 100% on that).
If you have visual studio installed on the build server you can just install the web workload (opening the solution will prompt it). I did this with Visual Studio 2019 today. MSBuild was ignoring not only my *.pubxml settings but even passed in properties via command line arguments to msbuild.exe (which overwrite the ones in the *.pubxml file).
I opened Visual Studio, it prompted me to install the necessary workload and I did. Everything started working as expected after that.
To precompile, in your pubxml file make sure to have this:
<PrecompileBeforePublish>True</PrecompileBeforePublish>
Also, this post refers to your Edit comment about how to get the build server to do it when it works on your machine.
Related
When publishing my web application, I get the following error:
Done executing task "CopyPipelineFiles" -- FAILED.
Done building target "CopyAllFilesToSingleFolderForPackage" in project
"ServiceManagement.csproj" -- FAILED.
Done building project "ServiceManagement.csproj" -- FAILED.
I use Visual Studio 2015. I also tried opening it in administrator mode.
One possible cause is, if you have included some files in the project that are not necessary to compile (like PowerPoint files or word files), & then removed the files from the hard drive, but forgot to delete them in the "Solution Explorer" inside Visual Studio - then "Rebuild Solution" will work b/c those files were not necessary to compile - but "Publish" will fail b/c it cannot find those files when Visual Studio tries to copy files to the publish destination.
I was able to fix it with the following actions:
Remove all unrelated scripts and libraries that you are not using on your project.
Remove all src folders on your scripts.
Since I copied the whole project script files with its corresponding directories, this was I think the main issue that cause the publishing to fail as some filenames are long.
I retain only the one javascript file and one minified file, the same way with CSS files.
If you weren't able to still solve the issue after doing the actions above, try the following (Either of this actions works for us.):
Try to rebuild the project on a different machine.
I am using Visual Studio 2015 Professional Edition so I tried the Visual Studio 2017 to build and publish it.
I kind of had this issue and was because of a corrupted file that couldn't sync in OneDrive. I had a folder that coudn't be opened or deleted with the message "tag present in the reparse point buffer is invalid". By making a "chkdsk /r /f" in a Command Prompt (w/ admin permissions) my build was fixed and I could publish it again in Azure.
I have a corrupted Publish profile.
I need to delete it. My other computer is fine, so I know it is local.
I have tried:
Clean checkout of codebase from Git (so nothing is local in my code directories).
Deleting C:/Users/<user>/AppData/Local/VisualStudio
Deleting C:/Users/<user>/AppData/Roaming/VisualStudio
Full text search of Profile Name 'MunicipalAgenda' through Registry
Full Text search through machine.
Creation of a new Windows User for Visual Studio Development.
Despite all of this, VS.NET is hanging onto that corrupted Publish profile.
Honestly I am at wits' end, and my next drastic step is to do a fresh reinstall of Windows 10. Please help before it comes to that!!!
Normally any publish profile store in particular project.
For that you have to look at following location.
Go to that project.
Project has special folder call Properties
Inside that there is a folder called PublishProfiles ( Something similar)
I also had some difficulty in getting my profile deletions to stick ... Visual Studio (2017) doesn't seem to be able to do it from Solution Explorer.
My latest attempt is to go to Source Control Explorer, open up the /Properties/PublishProfiles folder, and delete and commit the unwanted profiles from there. So far so good :)
I changed jobs this year, so due to that i switched from Java to C#.In both jobs I work/worked on a large application that is deployed to a server and exposes various webservices.
With the Java job, an ant build process created a .ear file that contained a .war file and other objects. This .ear file was deployed by copying it into a directory within a JBoss/tomcat server. I understood the process fairly well.
With the C# job, I press a green triangle "play" button in Visual Studio and the application is compiled and somehow deployed to IIS, and Visual Studio then starts up a web browser pointing to the application's URL. I don't completely understand what is happening under the hood during this process. We have a build server that creates production builds that go out to production servers, but I don't understand a) what artifacts are produced by the build process, and b) how are those build artifacts deployed to IIS.
I would like to understand the process well enough to manually drive builds and deployments, re-automate the process, and also troubleshoot and modify our existing build and deploy process. I can drive a build with msbuild, but what does that produce, and how would I get it deployed onto another machine's IIS installation?
What happens when you hit Run (the green triangle) is probably not the best example, because it is using a specialized form of IIS (sometimes called Cassini) hosted within Visual Studio with a debugger attached.
To get a clearer picture of what happens when deploying, use the Publish tool to deploy to a folder on your desktop. In that folder you will see what is essentially the web root. Your project, minus any code files, and a bin directory with the compiled binaries.
Typically only static files such as html, css, and png, etc. will be deployed, while any code files won't. By default Visual Studio "knows" which files to build into the binary, and which to simply copy to the output folder (and which to ignore). But you can change this in cases where you need to override that behavior, or you have a file type VS doesn't know about. In your solution explorer, right click on a file, select properties. In the properties window for that file you'll see "build action", which shows what VS will do with that file.
Hope that helps.
Just add a note.
So,
If you are working with ASP.NET Website, it should enough to manually copy it to publish folder
If you are working with ASP.NET Web Application, so before publish it should be compiled. All compile operations is performed by MSBuild - command line utility to buld .net projects. But how MSBuild can understand, what it should build and in what way? Easy - there special files with instructions for MSBuild - is solution files (example howto build project from command line "C:\...\MSBuild.exe" /maxcpucount:10 MyAwesomeSolution.sln). Solution file contains references to project files (and build order for projects, etc), project files contains references to files, which included in project (and type of project - library/console/web app/etc, and framework version, and action for each file - build/content/resource, etc). If some file does not included to project, it will be ignored.
So, when you press green button, firstly VS will run MSBuild to build your solution. Inside solution should be written, which project will be used as starting point and what should be done before/after build. Inside project there information, howto debug project (via IIS, IIS express or smthg else).
So, when we working with some CI server, to compile our solution is enough to run MSBuild on CI server with path to solution. Ofcource, to publish compiled solution via CI, additional scripts should be written (to cpy files, etc).
Also, if you want to publish you website to some location, you can create "publish profile". It allows you to publis your website to IIS, FTP, etc, but you have to press "publish" button manually (right click on web project => publish)
I have developed a responsive asp.net website using Visual Studio 2015 Community by choosing the default ASP.NET Forms template . On my local computer, the website runs perfectly fine, but when I uploaded all the files of the website to the internet server, I found that I am not able to upload three files with .exe extension namely "csc.exe","vbc.exe" and "VBCSCompiler.exe" under the path "/Bin/roslyn". I raised a ticket to my hosting provider net4india and they are saying that they don't allow .exe files to be uploaded on server as they may be potential viruses. I had earlier developed this website on Visual Studio 2010 and was working perfectly fine on the hosting server also , but I wanted to make it responsive and I don't know how to use bootstrap, so I had choosen the template for ready-made coding, but now this is a big problem. I have googled a lot on this issue, but not found anything even near to what I am facing , even on stackoverflow. How can I resolve this issue ? Is any work-around possible for this like converting the .exe to .dll files or anything like that ? Please help.
You can deploy even without Roslyn with no change in code. Open NuGet Package Manager window and uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and rebuild & republish. This will solve your purpose. Basically this will not generate any csc.exe, vbc.exe files inside bin folder.
No hosting provider will allow you to run exe files. If you really want that, you should go for (virtual) dedicated server.
I am building an application which is based on a sample application,
written in C# on .NET 2, and is built on VS2008. This application is mostly a wrapper for a COM application.
However I compile it in .NET 3.5.
The sample application came with the following files in it's bin\debug:
appName.vshost.exe
appName.vshost.exe.manifest
I noticed that I can delete the files and VS re-builds vshost.exe, and the vshost.manifest file appears with modification date the same as the deleted file as if VS has copied in from somewhere.
My question is, should I put this files in my SVN code repository?
Those two files you list implement the Visual Studio "hosting process". It is a hosted version of the CLR, designed to improve the debugging experience. It takes care of some security issues, the most visible side-effect is that it redirects output written with Console.WriteLine() in a GUI app to the Output window.
These files are not part of your project and do not get deleted when you use Build + Clean. In fact, you cannot delete the .exe file, it is always running while you've got the project opened in Visual Studio. You can disable the hosting process feature with Project + Properties, Debug, scroll down, "Enable the Visual Studio Hosting process" tick. There's no compelling reason to do so.
There's no need to check these in, Visual Studio re-generates them when you check-in a project and load it in VS. In general, you never need to check anything in from the bin subdirectory, its content is always re-created by building your project.
Everything in the debug (or release) folder is generated. Everything that's generated shouldn't be checked in.
When in doubt, just make a fresh checkout to some other folder (or even machine), and try to build from that. If something is missing, this will find it.
I do not think you should. They are for VS use only.
Here are the files I ignore when creating C# projects. You really only want to store the source code in the repository and not the outputs. Similarly you probably do not want to store the user based information that goes along with VS solutions.
*.csproj.user
*.suo
bin (folder)
obj (folder)