Rectangle 27 22

You can load the solution by using Roslyn.Services.Workspace.LoadSolution. Once you have done so, you need to go through each of the projects in dependency order, get the Compilation for the project and call Emit on it.

You can get the compilations in dependency order with code like below. (Yes, I know that having to cast to IHaveWorkspaceServices sucks. It'll be better in the next public release, I promise).

using Roslyn.Services;
using Roslyn.Services.Host;
using System;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        var solution = Solution.Create(SolutionId.CreateNewId()).AddCSharpProject("Foo", "Foo").Solution;
        var workspaceServices = (IHaveWorkspaceServices)solution;
        var projectDependencyService = workspaceServices.WorkspaceServices.GetService<IProjectDependencyService>();
        var assemblies = new List<Stream>();
        foreach (var projectId in projectDependencyService.GetDependencyGraph(solution).GetTopologicallySortedProjects())
        {
            using (var stream = new MemoryStream())
            {
                solution.GetProject(projectId).GetCompilation().Emit(stream);
                assemblies.Add(stream);
            }
        }
    }
}

Note1: LoadSolution still does use msbuild under the covers to parse the .csproj files and determine the files/references/compiler options.

Note2: As Roslyn is not yet language complete, there will likely be projects that don't compile successfully when you attempt this.

Is there a convenient way of determining the dependency order (like sln.ProjectsInDependencyOrder) or is this something I would have to implement on my own? (e.g. Going through project-references and building a dependency tree)

There is an IProjectDependencyService that has GetTopologicallySortedProjects(). I don't have a computer handy to check exactly how to get it, but will update later.

This solution doesn't work in the current preview 1.0.0-beta1-20141031-01. Roslyn.Services.Workspace.LoadSolution() doesn't exist, neither does Solution.Create(). I think you have to use MSBuildWorkspace.Create along with OpenSolutionAsync (for existing sln) or just workspace.CurrentSolution for empty one. As well, you'll need to install the MSBuild 2015 tools from microsoft.com/en-us/download/details.aspx?id=44931 in order to use an MSBuildWorkspace. Or, you can MEF export a catalog and use CustomWorkspace. The whole process has gotten much more complicated it seems

To add to @JoshE's comment, the Solution class now has a GetProjectDependencyGraph method that does all of this, once you have the Solution object.

How do I compile a C# solution with Roslyn? - Stack Overflow

c# roslyn
Rectangle 27 133

In VS 2012 (as well as the publish updates available in the Azure SDK for VS 2010) we have simplified command line publishing for web projects. We have done that by using Publish Profiles.

In VS for a web project you can create a publish profile using the publish dialog. When you create that profile it is automatically stored in your project under Properties\PublishProfiles. You can use the created profile to publish from the command line with a command line the following.

msbuild mysln.sln /p:DeployOnBuild=true /p:PublishProfile=<profile-name>

If you want to store the publish profile (.pubxml file) in some other location you can pass in the path to the PublishProfile.

Publish profiles are MSBuild files. If you need to customize the publish process you can do so directly inside of the .pubxml file.

If your end goal is to pass in properties from the command line. I would recommend the following. Create a sample publish profile in VS. Inspect that publish profile to determine what MSBuild properties you need to pass in on the command line. FYI not all publish method support command line publishing (i.e. FTP/FPSE).

/p:VisualStudioVersion=11.0

I think the OP simply wants to "deploy" the web app to an arbitrary folder on his local machine.

In that case create a File System publish profile.

so, on a deployment server a person would need to install the visual studios IDE to get a command like that to work?

Does this work in VS 2013? Running the same command line, produces no publish. No errors either. Testing with a simple file system deployment in a publishing profile. build works, jut no publishing result. Destination is empty.

visual studio - Using MSBuild.exe to "Publish" a ASP.NET MVC 4 project...

visual-studio msbuild asp.net-mvc-4 msdeploy
Rectangle 27 0

If you are using the <msbuild> task from NAntContrib, then you can set the OutputDir property like this:

<msbuild project="path-to-sln-or-csproj-or-msbuild" target="Build">
  <properties>
    <property name="OutputDir" value="build-outdir-dir" />
  </properties>
</msbuild>

not working, did you test it before ?

This answer is from seven years ago. I expect that I used this in a real project but I cannot remember. It's also possible that something in NAntContrib has changed behaviour since I wrote this answer.

asp.net mvc - How to tell MSBuild where to put my compiled files? - St...

asp.net-mvc msbuild nant