Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get property 'MSBuildProjectName' on null object when building a project file with assemblyInfoPatcher task #60

Open
gdurand opened this issue Apr 22, 2016 · 3 comments
Labels

Comments

@gdurand
Copy link

gdurand commented Apr 22, 2016

I have this error when the build is configuring. If I specify a solution file it works fine and if I specifify a project file and remove the task assemblyInfoPatcher it works fine.
The solution contains several projects.
The project and solution are attached: project_and_solution.zip

msbuild {
    //dependsOn << assemblyInfoPatcher
    //solutionFile = 'src/main/cs/' + project.name + '.sln'
    //projectName = project.name
    projectFile = 'src/main/cs/' + project.name + '.csproj'
    targets = ['Clean', 'Rebuild']
    configuration = 'Release'
    platform = 'Any CPU'
    destinationDir = "$buildDir/bin"
    intermediateDir = "$buildDir/msbuild/obj"
    generateDoc = true
    verbosity = 'quiet'
}

assemblyInfoPatcher {
    version = project.version - '-SNAPSHOT'
    fileVersion = project.version
}

The error (triggered by com.ullink.AssemblyInfoVersionPatcher$_closure5.doCall) :

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'Omega.Core'.
> Cannot get property 'MSBuildProjectName' on null object

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'Omega.Core'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:532)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:93)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
        at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: java.lang.NullPointerException: Cannot get property 'MSBuildProjectName' on null object
        at com.ullink.ProjectFileParser.getProjectName(ProjectFileParser.groovy:22)
        at com.ullink.Msbuild.resolveProject(Msbuild.groovy:137)
        at com.ullink.Msbuild.getProjects(Msbuild.groovy:69)
        at com.ullink.Msbuild_Decorated.getProjects(Unknown Source)
        at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:166)
        at org.gradle.api.internal.BeanDynamicObject.getProperty(BeanDynamicObject.java:109)
        at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:81)
        at com.ullink.Msbuild_Decorated.getProperty(Unknown Source)
        at com.ullink.AssemblyInfoVersionPatcher$_closure5_closure10.doCall(AssemblyInfoVersionPatcher.groovy:30)
        at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:110)
        at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:488)
        at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:58)
        at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:59)
        at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:202)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:115)
        at org.gradle.api.internal.tasks.RealizableTaskCollection.all(RealizableTaskCollection.java:187)
        at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:126)
        at org.gradle.api.DomainObjectCollection$withType.call(Unknown Source)
        at com.ullink.AssemblyInfoVersionPatcher$_closure5.doCall(AssemblyInfoVersionPatcher.groovy:29)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy13.afterEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
@gluck
Copy link
Contributor

gluck commented Apr 26, 2016

Hi, it's usually a bad idea to build a csproj outside of a solution context (e.g. nuget restores packages relative to solution directory, and solution configuration can alter configuration/platform for referenced projects), may I ask why you need to do it ?

That being said it'd be nice for this plugin not to crash in that scenario :)

@gluck gluck added the bug label Apr 26, 2016
@gdurand
Copy link
Author

gdurand commented Apr 26, 2016

In my solution, in Debug config, all the dependencies of my main project are built. For release I want only the main project to be built. I can achieve this by specifying only the main project in the Release config or create a "Debug Main" config, but I saw the option to build only 1 project in your plugin so I tried to use it. I can still work with the Release config and the solution. I just wanted to report a bug that is not so easy to figure out when first using the plugin.
BTW I'm new to gradle and the integration of Visual Studio into an automated build system. I come from maven/java and things are quite not the same, to say the least.

@gluck
Copy link
Contributor

gluck commented Apr 26, 2016

This is actually fixed by #58 already, will be in vNext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants