Visual Studio import .publishsettings for File System - asp.net

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.

Related

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.

Exporting entire project in Visual Studio 15

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 :)

ASP.NET Web Site Project with User Uploaded Files

I have an ASP .NET Web Site Project that is being moved into TFS. There is a folder that is used for user uploaded files (e.g., company logos, excel spread sheets, etc.) that need to be kept. I'm trying to figure out a good way to manage these files without placing the folder in TFS (it's really big), and make it easy for new developers to grab the folder structure to their local machines for development.
I was thinking of doing the following and was wondering if this is a good way of doing it, or if there are better alternatives:
Create a script which will, when executed, create the folder structure of the storage folder. This would be placed in source control.
New developers could grab this file and execute it on their local machine.
To make sure the folder is added to source control, get the developer to remove it from their local project.
Store the folder on a NAS - no need for the files to be part of the source-controlled code.

"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

How to update an asp.net website (just changed files)

I am developing an asp.net website that will need regular updates for source codes and HTML sides. After i have completed the necessary updates, i use the 'publish website tool' and publish the site to my local directory. Then i upload all files to Remote File. Is there any way to fix my site with just changed files. For example if i have updated just 2 files of 84 (HTML or source side), is it possible to update just this 2 files without any problem?
While Visual Studio does offer a few different compiling/build options, I think that you are probably doing everything just fine for a Visual Studio Website project. When I'm working with a website rather than a web application, I will only FTP the files that have changed. For example, if I were to change some HTML tags around within an .aspx page, then only that page would need to be uploaded to the web server. If I change the Page_Load function in the .aspx.cs page, then I will definitely need to get the updated DLL on the web server as well.
I use FileZilla for my FTP tool and there is an option to only upload the changed files. So after you use visual studio to publish your website, you can grab the entire contents of that directory and drag it over to the FTP server location and only update what has changed.
The ASP.NET website project offers an option in the Project properties -> "MSBuild Options" tabpage where you can set "Allow this precompiled site to be updatable".
Setting this option
"Specifies that the content of .aspx
pages are not compiled into an
assembly; instead, the markup is left
as-is, allowing you to change HTML and
client-side functionality after
precompiling the Web site. Selecting
this check box is equivalent to adding
the -u option to the
aspnet_compiler.exe command."
according to the docs.
I've been entirely underwhelmed by the available tools to VStudio. And am instead using Gulp.
Even in 2017 the problem remains.
With gulp you can "watch" directories for changed files, so I have it configured to watch the [bin] folder, along with assets separate from aspx/cshtml files.
That way whenever I change anything, it is instantly copied to my publish folder where I can later zip it up and deploy ONLY the changeset. The script even has a delay so I can delay the copy/upload in situations like bundles where they are generated dynamically and take some time to be fully modified.
The only thing I have to do is clean it up before I start my next milestone, so that the "publish" folder which gulp "auto deploys" to is empty and ready for the next run. Emptying a folder and running "gulp watch" in background seems like a small price to pay for such a needed feature.
I feel like this should be a good item to develop as a vstudio plugin.
Recently I have been forced to move to a windows/C#/.NET/MVC environment from linux/node/angular. Sigh. I found the following solution (next paragraph) elminates the pain caused when using visual studio to "publish" the code. The VS2017 publish process copies every file in the entire application to the web server, even if just one character is changed in one file. This can take over an hour for our moderately sized app.
So here's what I do. I first publish the solution locally (typically to bin/release/Publish/). That takes about 1 minute as opposed to 1 hour to publish to the server. Then, I compare the files between my local Publish directory and the server directory using FreeFileSync. FreeFileSync is amazing -- and free. I have access to the server directory via a windows file share. The compare takes about 15 minutes. I can then see exactly what files are different and need to be pushed. Note, the option I use compares the actual CONTENT of the files, not just the create time. I then use the FreeFileSync sync feature (mirror option) to copy the few files needed to the server. This takes maybe two minutes. So the total operation takes about 20% the time Visual Studio "Publish" takes. But best of all, the actual hit on the prod server is only the two minutes it takes to copy the diff files, rather than the 1 hour outage inflicted by Visual Studio Publish as it slogs along copying each and every file.
It depends on the type of project.
If is a project created with File > New Web Site then is ok to just copy the changed .aspx files (make sure that the corresponding code - .cs - files are also copied).
If the project was created with File > New Project > ASP.NET Web Application then you will need to copy the .aspx files and the compiled project dll (by default the dll has the same name as the project like TestProject.dll) from the bin folder inside the project.
i think you need something http://winmerge.org/
where it will compare files that are changed and upload them.
hope this helps

Resources