Exporting entire project in Visual Studio 15 - asp.net

I need to send off this project I've been working on via email so I'd like to just zip up the project folder and send it off. I've done this in previous version of VS with no problem but with Visual studio 15 the project folder only contains the solution file a .vs folder and a packages folder. None of the actual files are included i.e default.aspx and so on.. If I try to zip up this folder and send it off it doesn't open on the other end. I've tried exporting as a template but that didn't really work because it doesn't contain the solution file. Is there any easy way to just export the entire project so that it can be easily opened by another user on a different computer (They need to be able to see each individual file in the solution basically how you see it in the solution explorer)?

I use CleanProject for this, amazingly, it still does a fantastic job with my VS2015 projects. It cleans (removes bin/, obj/ etc) and then creates a minimum zipfile.
You can download it here:
https://visualstudiogallery.msdn.microsoft.com/bca632e0-3948-43c8-b337-da47275717b6
It does not work from VS2015, but from the file explorer. If that doesen't freak you out, it's a great timesaver for those situations :)

Related

Cannot rebuild ASP.NET Web Applicaiton missing solution file

I am taking over an ASP.NET Web Application using C# and all the code (including C# source) was given to me without the solution file (something.sln) so whenever opening the Web Application in Visual Studio 2017 I have to open by "Folder..." instead of by "Project/Solution...". Once open, I am able to make the necessary changes to the code behind files such as Default.aspx.cs or somethingElse.aspx.cs, but when I try to test the code changes by going to Run > Start Without Debugging, I couldn't find the Run menu option; I see the Build Solution button but it's disabled (greyed out).
Every time I try navigating directly to my site at http://dev.mydomain.com. The code changes I made did not get compiled neither.
So how do I get the Run or Build menu option enabled?
The easiest way to correct this issue is probably to create a new, empty ASP.NET WebForms project (and a new solution file as well if necessary) and copy your code files into it. You can then tell Visual Studio to "include" those files in the project.
You may (or may not) need to make the odd other minor adjustment too but those basic steps should get you started.
Not sure if this is related, but adding the sln file to the git ignore removed its visibility from VisualStudio. I had to open the project csproj file in VisualStudio.
THen on close, the prompt was asking me to save a new SLN file with the same solution name i was looking for. I was then able to go to the directory with the original solution in it, and then I was able to open it again in Visual Studio.
For all those who come to this post in the future, I would check your gitignore files and see if they ignored the sln file.

Is it a bad idea for my solution and project to be stored in separate locations?

Somehow my solution and project differ as to their Path/FullPath.
The Path property of my solution ("customerreportingnet") is:
C:\Users\cshannon\Documents\Visual Studio 2013\Projects\customerreportingnet\customerreportingnet.sln
The only project beneath that solution is a Website ("http://localhost/EMS/customerreportingnet/").
The website project's FullPath is this:
C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet
Why would the solution and project location differ?
Did I do something wrong in the setup? I downloaded the files from a .zip file, and extracted them to C:\EnhancedMonthlySalesReporting\
I then created a Virtual Directory in IIS, mapped it to C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet, giving it the Alias "EMS".
Then in VS I open the website (solution/project) this way:
File > Open Website...
and then I open IIS > EMS
When I do this, I do not see any files beneath the "project" - all that's visible in the Solution Explorer are just the solution and project names - no subfolders or files beneath them. But when I right-click the solution "customerreportingnet" and select "Open Web Site", then reply OK to "Open the Web site (this will close the current solution)" all is relatively well - I can right-click the project ("http://localhost/EMS/customerreportingnet/"), select View in Browser (Internet Explorer) and the site runs.
The only files in C:\Users\cshannon\Documents\Visual Studio 2013\Projects\customerreportingnet\ are:
customerreportingnet.sln
customerreportingnet.v12.suo
C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet has those files and many more (as well as beaucoup folders).
Should I try to reset the solution Path to C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet, or is that just an oddity, but not a problem?
If so, is that as easy as just changing that property value, or will that mess things up?
Is it a bad idea for my solution and project to be stored in separate
locations?
A solution is a "container" for projects. Where they are in your local file system doesn't really matter. So in that context, it's "fine".
It's not unusual to have some solution context that is composed of some "projects you did before". So you can "organize" a "new" solution composed of projects located elsewhere (from some other "solution") along with new items.
However, once you get into Source Control, whether it's TFS or GIT, then it will matter - they (projects in a solution) have to be in the same parent folder to be handled easily. So in that context, it's "bad".
TLDR; there are still ways to effectively source control "projects in different folders" - each one is it's own separate "repository". But you'll have to manually/separately do your syncing, merging, etc.
If I'm following your post correctly, I think what you're looking for is Add..., not Open... - you want to add an existing project or web site to a Solution.
Depending on what you're after, and what files you're dealing with:
if you have a Project in the zipped file, then you can Add Existing Project, and so on...
Unsure why you needed to do what you did in IIS - you can do debugging within Visual Studio (IIS Express).
Alternatively, you can Publish your web site/application from Visual Studio and target a local file system folder that you can then set in IIS (Local IIS if installed) - this way, you sort of have a "dev" (VS) and "staging" (publish folder mapped in IIS) environment in your local machine.
Hth...
After you extracted your code and opened the project in visual studio.
Visual studio will automatically create a solution file if you open a project (you can also open a solution file directly). Once you click save all or save your solution file it will save it to the previous location or to the default location.
Since you did not save the file before, visual studio will save it to the default location:
C:\Users\cshannon\Documents\Visual Studio 2013\Projects\[ProjName]\[ProjName].sln
If you want other developers to be easily able to open your project. (especially when you start to have multiple projects inside 1 solution), you want to include the solution file inside the project location. Otherwise every developer has to create this solution file himself, which is annoying and cumbersome work.
Since dotnet core the best practice file structure is this:
/root
/src <== contians all the projects per folder
/project1
/project1.csproj
/etc*
/project2
/[ANameForSolution].sln (so directly inside the proj folder, next to src)
The old habit people use was more flat:
/root
/project1
/project2
/YourSolution.sln
The best practice, moving everything to /src is because lately a root of the project already has a lot of (config) files, and this way you can keep the root a bit cleaner.

Visual Studio import .publishsettings for File System

Where/How do you create a .publishsettings file, so you can import a common configuration for all of your local, test deployments?
I want to publish another site locally to my computer via Visual Studio to C:\Webs\TheSite. Every time I do this for a new site, I have to create a new custom profile and go through and click all the checkboxes etc.
I would rather start by importing a pre-configured .publishsettings file, and just change TheSite in the destination path.
However, I can only find instructions for Azure and FTP/WebDeploy:
http://gauravmantri.com/2012/09/14/about-windows-azure-publish-settings-file-and-how-to-create-your-own-publish-settings-file/
http://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-get-started/
http://www.iis.net/learn/web-hosting/joining-the-web-hosting-gallery/generate-a-profile-xml-file
Surprisingly answer to this simple question is so hard to find. I wasted hours searching answer to this to save minutes in creating new profile. Well then I never knew it would take so much time.
The simple hack is to copy the "PublishProfiles" folder from previous project (from where you want to get publish profile) and paste it in present project in "MyProject" folder.
If you already have "PublishProfiles" folder in present project then copy only the relevant xxx.pubxml and xxx.pubxml,user files from previous project.
Then open the profile and edit it as you like.

"Add as Link" for JavaScript files returning 404 in debug

Using a Visual Studio 2010 ASP.net web application, I have several projects that share some JavaScript/css files. The most logical way for them to share these files is to place the files in a single folder and each project has them included with the "Add as Link" option. However, if I add the files this way when I'm debugging using either the Visual Studio Development server or debugging using a local IIS web server all requests for these files return 404 Not Found errors. If I publish the site then the files are copied but that obviously doesn't help with debugging.
Is there something I'm missing or is this a failing on VS's part?
To overcome this problem some time ago I created a 'MSBuild.WebApplication.CopyContentLinkedFiles' nuget package. This package adds MsBuild target which copies all content files added as link to project folder during build.
Note: if you use source control then it is better to add copied files (from Web Application folder) to ignore list.
I wouldn't really call that a failing, since you asked for that behavior in the first place: linked items in Visual Studio projects are actual links to external files. Those files can reside anywhere on the disk and are not copied into the project folder.
You might want to copy those files locally yourself during a pre-build event. That way, the files will remain synchronized and you won't duplicate them until your first compile.
The problem seems to be that the website runs right from your source folders, rather than from the bin folder. This means that the file will be missing, whether or not it is copied to the output folder.
It's probable that running from a local or remote web server would not have this problem, though I didn't get that working, and I'd rather not add IIS to my local machine if I don't have to.
Adding a pre-build copy command did work. Note that the current directory will be the bin folder. (You can use cd to echo the current directory to the build window if you want to see it):
If the file is in another solution, your command will look something like (three ..s: one to get out of each of bin, project, and solution folders):
copy ..\..\..\OtherSolution\OtherProject\Scripts\MyJSFile.js ..\Scripts\
If it's in the same solution, but a different project:
copy ..\..\OtherProject\Scripts\MyJSFile.js ..\Scripts
One minor issue is that the link to the file will collide with the new copy of the file, even if you don't add it to your project. As long as you make the link first, it seems to work. If you copied the file first, you'll have to manually delete the copy, and then refresh the solution explorer before before being able to add the link.
Select the link in Solution Explorer and then look at properties window and set Copy To Output Directory to Copy Always. Linked items are set to Do Not Copy by default.
BTW, you can copy many files as links very easily directly from Solution Explorer when using VSCommands 2010 extension.
See this blog post about a simple addition to your project file.
http://mattperdeck.com/post/Copying-linked-content-files-at-each-build-using-MSBuild.aspx

TortoiseSVN with ASP.net Web Projects - How to manage this?

We're a small team starting to use TortiseSVN to manage our web projects.
I was just wondering what is the best way to manage web projects into Subversion.
As you know a web solution consists of the .sln file as well as all the .aspx files.
Well we noticed when we right click the solution and we select "Add selected projects to subversion". It prompts me to tell it where to store the .sln file. So I give it some path like svn://serverName/CIS/MyWebSiteProject. Cool it just placed the .sln file...so I thought to myself how is it going to store the .aspx files as well.
Within a second I got a second prompt, I thought cool it is prompting me for the .aspx pages. So I tried giving it the path svn://serverName/CIS/MyWebSiteProject/ASPX_Files, but it comes back with an error stating I cannot place this folder within this path. I actually have to go outside of the folder MyWebSiteProject.
Not good cause now I have 2 folders one with the .sln folder and the other with all the .aspx pages and these folders are sitting on:
(sln file):
svn://serverName/CIS/MyWebSiteProject
(aspx files):
svn://serverName/cis/myWebSitePages
This really is not ideal cause I am sitting on the root of CIS with 2 folders for really one solution. Now when I try to check the project out I have to check both folders out.
What makes this even worse is when I do check them out I try to open the .sln file and I get an error that it cannot find the corresponding .aspx files. This seems like too much work, is there an easier way or a recommended way of using tortisesvn/subversion with asp.net web projects ?
While I am sure you have TortoiseSVN installed, it sounds like you are using Ahnk or some other VS SCC plugin to add from within VS.
I would suggest not using the plugin to initally add the solution to SVN, but to use TortoiseSVN in Windows Explorer for your initial check in. This will add your solution directory in its original state.
From that point on, you should be able to use the SCC plugin from within VS without trouble.
EDIT
Ok, after your commment I realize that I was not fully understanding the problem.
If you are dealing with a single project, after you create your solution and project, select the solution in Solution Explorer, go to 'file>save solution as' and save the solution inside the directory where your project file is.
Close the solution and go out to Explorer and use Tortoise to add the directory to SVN. If you have multiple projects/sites, just pick one to hold the solution.
Does that make sense? and from that point you should have no problems with ahnk
The key to successfully using Visual Studio with any source control is to put the solution file in the same path as the rest of the project files.
Usually, I will do something like the following:
\Project\Project.sln
\Project\MainWebSite\*.* <-- All web site files (including .??proj here).
\Project\Library\*.*
Then, I manually put \Project\*.* into source control.
Other options exist, as for my recent projects, I have been using:
\Project\SolutionFiles\Project.sln
\Project\MainWebSite\*.*
\Project\Library\*.*
Again, I manually put \Project\*.* into source control.
I generally find that it is better to set up the repositories for my solutions and projects from within Tortoise SVN. Then use whatever VS plugin that you care for to manage the commits of your pages etc. This gives you a little more control and allows you to get your setup correct from the start.

Resources