gradle-msbuild-plugin icon indicating copy to clipboard operation
gradle-msbuild-plugin copied to clipboard

Project files not found by AssemblyInfoPatcher if in different directory from solution

Open chefhoobajoob opened this issue 8 years ago • 7 comments

I have a source tree like so, where the solution file defines the paths to its constituent projects:

<root>
   +---rootProject.sln
   +---src
        |
        +---project-a
        |       +---project-a.csproj
        +---project-b
                +---project-b.csproj

This minimal configuration appears to successfully build every project in the solution:

msbuild {
  solutionFile = 'rootProject.sln'
  targets = ['Clean', 'Rebuild']
  configuration = 'Release' // this should be included in the Readme
}

And, I was hoping that setting the assembly versions for all of the projects would be as simple as:

assemblyInfoPatcher {
  version = project.version + '.0'
  fileVersion = version + '.' + buildNumber
  projects = 'project-a', 'project-b'
}

...but no matter what I configure for the patcher, even if I omit the projects configuration, the patcher always complains:

Project project-a not found in solution

So, it appears that the patcher is not expecting or using the path information that is specified in the project entries for the solution file.

chefhoobajoob avatar May 19 '16 15:05 chefhoobajoob

This should work, do you have the full stack of the error you get ? (gradlew -is) The patcher only patches the main project by default, because it wouldn't make sense to patch NUnit projects (for instance) in same solution, but listing the project names as you did is the expected usage.

Thx !

gluck avatar May 19 '16 15:05 gluck

It's not very informative, but here's the output from gradlew -is leading up to the message above:

Starting Build
Settings evaluated using settings file 'C:\master\settings.gradle'.
Projects loaded. Root project using build file 'C:\Users\hoobajoob\Documents\rootProject\build.gradle'.
Included projects: [root project 'rootProject']
Evaluating root project 'rootProject' using build file 'C:\Users\hoobajoob\Documents\rootProject\build.gradle'.
Parsing file C:\Users\hoobajoob\Documents\rootProject\rootProject.sln ...
Project project-a not found in solution

chefhoobajoob avatar May 19 '16 15:05 chefhoobajoob

This error suggest you configured msbuild task with:

msbuild {
    project = 'project-a'
     ...
}

It also doesn't seem to be relevant to the assembly info patcher task, so you'll probably still have the error if you remove the task (do you ?). Maybe attach you sln content ?

gluck avatar May 19 '16 16:05 gluck

There are other problems - the msbuild command that is run does not appear to honor the Visual Studio version specified in the solution file.

Here are the first few lines of the solution file:

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "project-a", "source\project-a\project-a.csproj", "{604034BF-0738-44A4-96B7-5D8F5EAA9ADB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "project-a.test", "source\project-a\project-a.test\project-a.test.csproj", "{54ACF628-D702-4EA1-9460-138A8FFE89A2}"
    ProjectSection(ProjectDependencies) = postProject
        {604034BF-0738-44A4-96B7-5D8F5EAA9ADB} = {604034BF-0738-44A4-96B7-5D8F5EAA9ADB}
    EndProjectSection
EndProject

...note that it is a Visual Studio 2010 solution. But, here is the output from gradlew -is:

Executing task ':msbuild' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Resolved MSBuild to C:\Program Files (x86)\MSBuild\14.0\bin\
Starting process 'command 'C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe''. Working directory: C:\Users\hoobajoob\rootProject Command: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe /nologo C:\Users\hoobajoob\rootProject\rootProject.sln /t:Clean;Rebuild /v:normal /p:Project=project-a /p:Configuration=Release
Successfully started process 'command 'C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe''
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 5/19/2016 8:39:55 AM.

...it appears to be using whatever the latest version of Visual Studio is installed on the system, rather than what's specified in the solution file.

This is the msbuild config in build.gradle:

plugins {
  id "com.ullink.msbuild" version "2.14"
}

msbuild {
  solutionFile = 'rootProject.sln'
  targets = ['Clean', 'Rebuild']
  configuration = 'Release'
}

assemblyInfoPatcher {
  version = project.version + '.0'
  fileVersion = project.version + '.' + buildNumber
  projects = [ "project-a" ]
}

chefhoobajoob avatar May 19 '16 16:05 chefhoobajoob

Curioser and curioser.

When I remove the patcher config, the not found in solution message goes away.

But, I should have checked the AssemblyInfo.cs file, because despite this message, the version number is getting substituted.

Not sure what the message is telling me, but it appears to be a red herring.

Unfortunately, I can't get it to run the right version of msbuild, though. Any ideas there?

chefhoobajoob avatar May 19 '16 16:05 chefhoobajoob

Should I open a separate issue for the msbuild version?

chefhoobajoob avatar May 19 '16 16:05 chefhoobajoob

You can configure the msbuild version like that:

msbuild {
    version = '10.0'
}

Regarding the other error I'm out of guesses sorry.

gluck avatar May 30 '16 08:05 gluck