28

I am having problems getting my C# Solution to build "Fresh". If I clean the solution and build it again it will not build (I can do it a few times and it will build). It has an error about the azure project getting build before the worker and web projects that it is dependent on. Also about how most of the projects in the solution are looking for

WAT070 : The referenced assembly {...}/Worker.dll was not found. 
Please make sure to build the role project that produces this assembly before building this Windows Azure Cloud Service Project.
{...}\VisualStudio\v12.0\Windows Azure Tools\2.2\Microsoft.WindowsAzure.targets 1252    5   AzureProjectName

Now if I build the projects in the order listed in the Project Dependencies -> Build Order everything works. Also, the web and work role are listed before Azure Project.

lockwobr
  • 1,461
  • 1
  • 15
  • 24
  • Are you able to confirm that Worker is a dependency of Windows Azure cloud service project? e.g. in Dependencies when Windows Azure close service project is selected in the Projects dropdown, Worker is checked? – Peter Ritchie Dec 06 '13 at 19:39
  • Yes, that is the case. Both Roles are shown as dependencies of the Cloud Service Project. – lockwobr Dec 06 '13 at 23:14
  • From what I remember(it has been some time now), the problem was that there was a dependency in one of the azure projects to the other azure project. Once I removed the dependency from web azure project to worker azure project it could build "Fresh" without having to build the project twice or with 1 build thread. – lockwobr Mar 12 '14 at 20:39

6 Answers6

34

Solution is very simple.

You can set your project build order by right click on 'Project Solution' and select "Select Project Build Order" option.

enter image description here

For Example, I have a WpfFormApplicaiton1 and two class with title "ClassLibrary1" and "ClassLibrary2". By default Visual Studio sets it as follow:

enter image description here

My requirement is such as "ClassLibrary2" will be used by "ClassLibrary1" & "ClassLibrary1" will be used by "WpfFormApplication1". So, in order to fulfill this requirement I have to change the default project build order.

Go to Project Dependencies; Select the "ClassLibrary1" and set the "ClassLibrary2" as its dependency.

enter image description here

Similary, select the "WpfFormApplication1" and set the "ClassLibrary1" as its dependency.

enter image description here

Now, the desired project build order is set; confirmed by Project Build Order's options.

enter image description here

Solution is taken from my blog.

Hassan Rahman
  • 4,953
  • 1
  • 34
  • 32
  • 6
    Solution is not very simple when you've done all this and it still doesn't work. Case-sensitive caching of project reference GUIDs turned out to be our problem, see the other answer on this page http://stackoverflow.com/a/23699611/503688 – yoyo Feb 22 '17 at 01:21
17

Your issue may be that the Dependencies are not defined. Even though the Build Order shows the order in which projects are built, if you do not define the dependencies for each one under Project Dependencies, msbuild will not know to wait for the dependencies build to complete before moving on.

To clarify: Unless you actually check the box that an item is a dependency, the projects in the build order list may build in parallel and not sequentially.

You can see under Tools->Options->Project and Solutions->Build and Runthat there is a default value for the number of parallel projects to build. enter image description here

So to make the build process wait for dependencies to build make sure that all of the "Depends on" fields are checked for the projects needed under Project Dependencies -> Dependencies.

Community
  • 1
  • 1
malexander
  • 4,522
  • 1
  • 31
  • 37
  • 1
    The number of parallel projects should not have any effect on this. Otherwise single CPU computers could never build right. – Peter Ritchie Dec 06 '13 at 19:10
  • 1
    Plus, the OP does detail that building in the order shown in the "Dependencies" works; so, one could only assume there *are* dependencies defined – Peter Ritchie Dec 06 '13 at 19:11
  • 1
    @PeterRitchie - The parallel projects setting defaults the number of available cores and I havent tried to increase it to more but I am sure that wouldnt work. As for if what I said in my answer, I just tried this on a solution with two projects, toggling the checkboxes on dependencies does dictate if they both build at the same time, or if they are built sequentially. Even if the build order list was the same both ways. – malexander Dec 06 '13 at 19:31
  • 1
    Maybe I need to clarify my answer, but what I was trying to relay was that unless you actually check the box that an item is a dependency, the projects in the build order list may build in parallel and not sequentially. – malexander Dec 06 '13 at 19:36
  • @PeterRitchie One _couldn't_ only assume that there _are_ dependencies defined just because OP states he can build the order shown manually. The build order list is populated with or without dependencies defined. – malexander Dec 06 '13 at 20:00
  • 2
    So when I drop the number down to 1 it does build. Still Trying to find the "missing dependency" but is hard with 21 projects in the solution. – lockwobr Dec 06 '13 at 23:41
  • This fixed my problem. In VS 2015 update 3 I had the problem that even though a project is clearly marked as a dependency of others, the solution build was failing because one of the dependencies was not complete before the dependents were started. – trashrobber Dec 07 '16 at 16:25
6

We had an issue where the project guids differed in case. Editing the project files solved the issue. We changed all Guids to uppercase

  • You sir, are my new hero! This fixed our weirdly intermittent and inconsistent "rebuild solution" errors. Visual Studio must have an internal cache with inconsistent reliance on case of the GUIDs. Wow. – yoyo Feb 22 '17 at 01:19
4

I just had this issue too. In my case the issue was that I had several project references within the solution. The other projects were using a different version of the framework to my Worker Role (4.5.1 vs 4.5).

When I changed all projects to use the same version of the framework the solution builds and runs successfully.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
3

I had this issue. In my case, the solution's project build order, as determined by VS.Net, was not correct. Specifically, my web project was listed above three of its dependencies.

These three dependencies were listed under in the References node of the web project in the Solution Explorer. However, in the dialogue Project Dependencies, the web project did not depend on any project.

Also, I noticed that the web project had a small blue exclamation mark, with hoover-over message "The Web project '' requires SQL Server Express, which is not installed on this computer. ...". After fiddling with the web.config, based on ASP.NET Web Api: Project requires SQL Server Express and reloading the project, the exclamation disappeared and the project dependencies were correctly checked in the dialogue Project Dependencies and the build order reflected this correctly. However, when I reverted the changes to the web.config, as a test, the dependencies were not removed, so I am quite unsure what fixed my issues.

Anyway, in the dialogue Project Dependencies, you can manually check any project which was not automatically identified as a dependency.

Community
  • 1
  • 1
R. Schreurs
  • 8,587
  • 5
  • 43
  • 62
0

Check to make sure there aren't any residual old files in your working folder. These can cause confusions with MSBuild. To avoid that, simply blow away all the old files in the path and get latest.