1

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?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

2 Answers2

3

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...

EdSF
  • 11,753
  • 6
  • 42
  • 83
  • Thanks; I did it this way (File > Open Web site...) because those were the instructions given me by the person handing me the project. I know that no matter which way I do it, I'm going to run into challenges, and if I deviate from his precise instructions, he will feel justified in saying that's why it's not working. I did try to simply open it as a solution in VS, but have problems with that, too. If interested in that story, see http://stackoverflow.com/questions/42450617/why-is-my-file-supposedly-unable-to-be-read-due-to-insufficient-permissions-htt – B. Clay Shannon-B. Crow Raven Mar 03 '17 at 15:42
  • 1
    @B.ClayShannon A web site or project is simply what they are (no magic). In your steps in IIS above, instead of adding a _virtual directory_ try `Add New Web Site` so it becomes it's own Application (that you can manage on it's own - app pool, etc.) instead of some "child application" (of some parent). Unless of course it is meant to be a "child" of a parent app already "installed" in your local machine. – EdSF Mar 03 '17 at 16:22
  • Would adding a Web Site this way, pointed at the same files, hose things up? The last thing I want to do is foul up the little bit of progress I've already made. – B. Clay Shannon-B. Crow Raven Mar 03 '17 at 19:53
  • 1
    It shouldn't. But if you're wary, you can simply unzip again, to a new folder, `Add A New Web Site` and point it to that new folder. Of course, with all the other requisite IIS settings (bindings, `hostname`, and your `hosts` file). Now you have "another instance" completely separate from everything you've done so far (clean slate). – EdSF Mar 03 '17 at 20:52
  • I don't recall doing anything explicitly with bindings, hostname, or hosts file yet. – B. Clay Shannon-B. Crow Raven Mar 03 '17 at 21:01
  • 1
    You'll need to get to those tasks if you're using Local IIS - so you can have as many "web sites" as you want - all completely separate from each other. In VS, this would be done for you automatically - VS/IIS Express will use port numbers (instead of hostnames, and mucking with `hosts` file) to differentiate from each other. – EdSF Mar 03 '17 at 21:18
  • Yeah, if only I could get past my 500.19 problem trying to run it as a solution via F5, I have a feeling it would be much smoother sailing. – B. Clay Shannon-B. Crow Raven Mar 03 '17 at 22:01
1

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.

Joel Harkes
  • 10,975
  • 3
  • 46
  • 65