Point To Referenced Projects
Sorry in advance if this is a REALLY simple question. I've done very little with msbuild other than:
msbuild.exe mySolution.sln
Is there a way to call msbuild from the command line and say compile a specific sln, but looking for project references in alternate locations? Such as:
msbuild.exe mySolution -projectref D:\mylocation\myproject.csproj -projectref D:\my2ndLocation\my2ndproject.csproj...
Thanks!
Eric,
Do you mean to change the paths to the projects in the solution? Solution stores relative paths to all projects inside it, for example if you have the following structure:
- Source
- Project
project.csproj
solution.sln
solution file will contain reference to the project as "project\project.csproj", and it is not something you can change for the build. The solution file actually serves as a container for the related projects and dependencies between them, and that information can be changed if you change a solution only.
Does that make sense? What is it you are trying to accomplish?
Cheers, Eugene
I'm doing an automated build, Eugene, and my developers have different paths than I would like for the build. If I were using NAnt, I would just:
Code Snippet
<solution configuration="release" verbose="true">
<projects>
<include name="${build.dir}\MyApp\MyApp.csproj" />
</projects>
<referenceprojects>
<include name="${build.dir}\MyProjReef\OtherApp.csproj" />
<include name="${build.dir}\MyProjReef\OtherApp2.csproj" />
</referenceprojects>
</solution>
So you're saying there's no way to do the same gig in MSBuild without creating and maintaining a separate solution file.
Eric,
Several things. First of all, solution file is not in MSBuild format. What happens when you build the solutions is that the temporary MSBuild script is generated and then it is used for the build. If you want to have a look at it you can read here on how to get this temp file.
The idea of the solution is that it stores paths to the projects and dependencies between projects, so when you build it all projects will be build in the right order. In your NAnt script, how do you assure that? If you want to manage dependencies between projects yourself, it would be very simple to create similar script in MSBuild using MSBuild task.
Overall, I do not see why would you need to have to manage that relative paths at all. For your example, it is sufficient to create solution that will contain these three projects in a structure like that
- Build dir
- MyApp
- MyProjReef
solution.sln
So if you want to change the path, you just place those two folders and solution in different dir. Or am I missing something?
Regards, Eugene
The NAnt solution task figures out build order for you. It checks references and builds in the right order for you so that you don't have to know the order. I'm guessing that the MSBuild task does also because the schema was developed based on NAnt (manager at MS for the MSBuild project was on the NAnt forum quite a bit when they was developing MSBuild). They did such a good job that NAnt can't support Web Sites because Microsoft locked them out by changing the design away from NAnt being able to work with it. So I'll dig around in the MSBuild task, because it's necessary now...
I am not sure what you mean as I am not very familliar with NAnt; what I do know is that the solution file is part of VS and not of MSBuild. Solution file serves more objectives than just building, and that's why they need to create the build script based on solution file.
Personally, I would recommend to have related projects in the same solutions and use VS mechanism for inter-project dependencies. Then you can easily use the solution for your builds.
Cheers, Eugene