.NET Framework Bookmark and Share   
 index > MSBuild > Solution build fails to add ProjectReferences properly
 

Solution build fails to add ProjectReferences properly

I have a solution that has several projects in it. The base project (or project that is required for all other projects) is a Data project that creates the data access objects (which are Entities). I have two other projects that reference this base project by a ProjectReference. When I build using the solution file, the build fails stating that it can't find any of my Entity objects. However, when I build each of the two dependent project separately using their project files (.csproj) they both succeed. Looking at the log the solution build reports:

Task "AssignProjectConfiguration"
Project reference "..\Data\\Data.csproj" has not been resolved

The project build doesn't have this task and resolves the project reference without any difficultities. I know this works for other project references so I am just wondering what I am missing and why this is a problem. Has anybody else seen this?

Thanks,
Craig
Craig Campbell
Craig Campbell
Final update and then we can close this thread.

The fix was actually quite simple:

1. Remove the reference
2. Add the reference as a ProjectReference
3. build

It looks like the project GUID changed somewhere in the middle of all our initial coding.

Lesson learned: Try to keep the warnings in your code to an absolute minimum. Thenwhen the build keeps throwing a warning that a project GUID can't be found, it won't be overlooked.
Craig Campbell
Craig Campbell
Hi Craig,

Please make sure that the Data.csproj is included in the solution.Otherwise, you have to specify property: BuildingSolutionFile to be false.

Task "AssignProjectConfiguration" is defined in Microsoft.Common.targets file.

        <!-- Assign a project configuration to each project reference if we're building a solution file. -->
        <AssignProjectConfiguration
            ProjectReferences="@(ProjectReference)"
            SolutionConfigurationContents="$(CurrentSolutionConfigurationContents)"
            Condition="'$(BuildingSolutionFile)'=='true'">

            <Output TaskParameter="AssignedProjects" ItemName="_ProjectReferenceWithConfiguration"/>

        </AssignProjectConfiguration>
It only executes when building solution file.
Within the task, it goes through all project references and findthem in solution configurations.The erroris reported when the task can't find the project in solution configuration.

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Hongye Sun
Unfortunately it is in the solution file. Visual Studio builds the project correctly everytime, whether it is a build or rebuild. The commandline is what fails on a Rebuild. I've already traced the execution path, but can't figure out why Data.csproj can't be resolved during a commandline (msbuild) run. This is the only project that I've run across this issue. We've found a workaround, but this is still disconcerting.

Workaround:
Remove the ProjectReference and add a file Reference. Verify that the build order and build dependencies in the solution are correct. Build is successful with a solution build from both VS and commandline.

Note: This breaks project builds from the commandline (in other words, Data.csproj always needs to be run manually before trying to build any other projects that depend on it).

If there is more information I'd be glad to try and figure it out, otherwise we'll be going with the workaround.

--Craig
Craig Campbell
Craig Campbell
Final update and then we can close this thread.

The fix was actually quite simple:

1. Remove the reference
2. Add the reference as a ProjectReference
3. build

It looks like the project GUID changed somewhere in the middle of all our initial coding.

Lesson learned: Try to keep the warnings in your code to an absolute minimum. Thenwhen the build keeps throwing a warning that a project GUID can't be found, it won't be overlooked.
Craig Campbell
Craig Campbell

You can use google to search for other answers

Custom Search

More Threads

• MSBuild with C/C++
• Batching a target without using the Inputs and Outputs parameters
• Recursively Compile Projects
• Property notation decision
• Browse Information set to None disables compilation
• Question about msbuild with other tasks than getting sources or compiling projects
• how to change the OutDir macro
• commandline build fails, ide does not
• MSBuild complete reference
• Build problems with fresh enlistment of VS 2005 solution containing mixed native/managed C++ project