0

Lets say you have a solution with projects A and B. A needs to B be build at least once so in order to be built with MSBuild i need it to be some kind of reference to setup the order of build. But setting up the projects as a reference made it build always together and project B its slow to build while A alone its fast and its the one I need to build multiple times from Visual Studio.

Is there a way to still make MSBuild take the order B -> A on building while beeing capable of build only A from Visual Studio?

I tried to setup a .proj for MSBuild but i kinda dont really understand how it works. I tested putting the reference from .sln with

ProjectSection(ProjectDependencies)

and in .csproj with

   <ProjectReference Include="..\B.csproj">
        <ReferenceOutputAssembly>false</ReferenceOutputAssembly>

edit: The reason why B needs to be built from time to time its that it can change too and its part of a repository and bin needs to be in .gitignore

edit2: In my case i was modifying some .proj that builds a lot of sln with this exact struct and in the end the "better" aproach was just modifying the sln file to put the project B first and done. 🙃

5
  • If project B has been built and is up to date, it should not be built again. If project B is building every time, something is breaking the incremental build. A common issue is using "Copy always" instead of "Copy if newer" in the "Copy to Output Directory" setting for a file. The build logging can provide details. Commented Jul 3 at 13:05
  • i added an edit so now its more clear
    – TSDrake
    Commented Jul 3 at 14:34
  • If you have a solution with projects and references between the projects, the meaning and purpose of the ProjectReference is essentially "go to this project, check if the project is up-to-date, build the project if it is not up-to-date, and copy the project's outputs". You can't tell the solution to build A and ignore building B regardless of its state. Is project B always out of date? That could be an issue in the project. Or project B could have its own separate build that produces a NuGet package and project A uses a PackageReference to the NuGet package. Commented Jul 3 at 16:27
  • If project B has its own repo, it probably should have its own build. Commented Jul 3 at 16:29
  • Project B uses some json files to generate dynamic classes and then a lot of dlls. And with these dlls its what I work in project A
    – TSDrake
    Commented Jul 4 at 6:21

0

Browse other questions tagged or ask your own question.