Visual Studio Web Deployment for Multiple Project Solutions - c#

We've recently started using the Web Deployment method offered in Visual Studio. For projects that have a single project in each solution, the deployment works fine and all files are copied correctly to the IIS server.
However, we have some solutions that have multiple projects in them. (2 or 3 projects...never any more than that.) There is a main project and some additional sub-projects. When the deployment happens, all the source .aspx and .cs files from the main project are copied to the server as well as all the output files in the bin directory, however the .aspx and .cs files from the sub-projects are not being copied to the server.
How can I get the deployment process to include the other supporting files in the sub-projects?

Related

Linking files when publishing a project

I have a project that I wish to publish. currently, I hardcode some reference files (.json,txt, and .ico) to be used in my project, which reside in a folder on my desktop for testing purposes. now that I feel I'm close to a version 1.0 release I want to migrate my resources to a applications folder upon install. basically want to create these files when the app is installed.
2 big questions I have is how to reference to the application folder that doesn't exist yet, and how do I publish the setup project.
I have the setup project installed for VS2019, and followed a quick and brief blog on how to use it. but I haven't found out how to publish that setup project. I can publish my project with my actual code in it, but I cannot publish the setup project.
below is a screenshot of the setup project. and i will add screenshot of my settings for the reference file.
Add the files into subfolder of your project and in the options part in Visual studio set that files will be copied to "debug"/"release" folder.
You will have an output folder with all what you needs and can be shippable.

update a web project by changing single aspx.cs file

I have to fix a legacy web service project created in C# and asp.net. It is not possible to open the project in visual studio as source safe errors and other missing libraries cause too many compile errors. I am not that familiar with web applications in .NET.
Is it possible to update a single aspx.cs file in the website directory which has a connection string hard coded that needs to be updated. If so, how is this eventually compiled and updated in IIS?
After you've deployed to IIS, you cannot update the .cs file in ASP.net application as they are already compiled into .dll files in the bin folder. The files you can update are with extensions like .aspx .ascx and .config etc. You should modify the .cs file, compile and publish the dll into the bin folder.

What happens when I deploy a .NET web application?

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)

The code behind file is not being updated when published to IIS

I am working on an ASP.NET project which is published to a configured IIS in the same machine.
I have made changes in one of the forms and than published it.
But while the changes on the web from file (.aspx) are being updated - other changes which reside in the code behind file (.aspx.cs) are not being updated.
My aim is to search addresses from a database and to display markers on google map.
Everything is working fine from my VS-IDE execution but after publishing it to the local IIS:
The front end is working fine while the back-end (the related .aspx.cs) does not work.
I tried those steps to remedy the situation:
I have deleted app directory from windows/frameworks/4.0/temp files.
I have even made new profile in publish wizard and published the project from a new folder.
I have deleted pool from IIS and made new one and mapped it to new ddl files folder.
I have also gone to project /properties/publish web/items to deploy and set to all files in the project.
But none of that solved the problem........
I am using
VS 2012
SQL Server 2012
EF 4.5
Do a clean and rebuild, then publish. Sometimes, sometimes, a change to a dll won't be detected and so won't be recompiled.
Try to delete everything in the bin directory wherever you're publishing the site, then try to publish again. Sometimes VS doesn't like to overwrite the dlls when publishing.
This is very late but search brought me here. The solution that worked for me was, in Visual Studio:
In solution explorer, right click on your project -> select "Build Dependencies", remove any incorrect dependencies.
In solution explorer, go to Project -> References, remove any unnecessary references.
Make sure your project is selected in solution explorer, on PROJECT top menu, select "Convert to Web Application." Ok.
Clean and Rebuild your project.
Publish. It helps to set your File Publish option in Publish Profile to "Delete All Existing Files Prior to Publish"
The code behind files do not get uploaded, because they don't need to get uploaded. Only config and markup files. All the project code is contained in your project's DLL file in the BIN folder.
Hope this helps somebody out there.

Is Visual Studio 10 expected to compile C# files that are not part of the solution?

Got a Visual studio 10 solution for ASP.NET web site, and VS seems to compile *.aspx.cs files that are in the web site folder, that used to be part of the solution but were excluded (I no longer see these files in the solution explorer). Is it expected? If not, how could I fix it? Rebuilding solution does not help.
Also, is it expected that I cannot find the binaries for *.aspx.cs files?
If your website is a Web site project as opposed to a Web application project (see Web Application Projects versus Web Site Projects in Visual Studio) then IIS will perform the compilation at runtime for you instead of Visual Studio - in this case the .csproj file is not used to determine what is and isn't compiled.
There is no project file (.csproj or .vbproj). All the files in a folder structure are automatically included in the site.
I'm not sure where the compiled binaries go, but I believe that it is a temporary folder somewhere, so you shouldn't necessarily expect to see those binaries in the web site folder structure.
If you want explicit control over what is compiled and when it is compiled then you may be better off converting your project to a web application project.
Short answer: No. It only compiles whatever is is included in the .csproj marked as 'compile' (in the file properties window).
Try to refresh the project, open the .csproj as a file text and check if those files are referenced there.
Lastly, it might be a dependent project that references those files.
If you can't find the solution, paste the exact error given by VS
For clarification, solutions files (.sln) contains project files (.csproj); .csproj files are the ones that contain references to the files to build.

Categories

Resources