Itiviti / gradle-dotnet-plugin

Gradle plugin for interacting with dotnet cli
Apache License 2.0
19 stars 8 forks source link

Built artifacts? #14

Closed ndw closed 3 years ago

ndw commented 3 years ago

Hello,

The dotnetBuild task completes, but I don't understand the results. I'm not sure I know what correct results should be, but looking in build, I see these directories: tmp/dotnet/{obj,bin}/Debug/net5.0/ref

I expected "release" builds, not "debug" builds, given my config:

dotnet {
  dotnetExecutable = '/usr/local/share/dotnet/dotnet'
  solution = 'XmlResolver/XmlResolver.sln'
  configuration = 'Release'
  verbosity = 'Normal'

  restore {
  }

  build {
    version = "3.0.1"
    packageVersion = "3.0.1"
  }  

  test {
    collectCoverage = true
    nunit {
      testOutputXml = file("${buildDir}/reports/nunit")
    }
  }
}

Also, there are no build artifacts that appear to have anything to do with my project libraries. I get several flavors of ProjectFileParser.dll but nothing else.

User error again?

ngyukman commented 3 years ago

hi @ndw can you try running the build by ./gradlew dotnetBuild --info and post your output? unlike ordinary gradle artifacts, normally the artifact is next to the .csproj bin/Release but not in build

if you wish to get the output path of the artifact, you could get by project.dotnet.mainProject.outputPath

ndw commented 3 years ago

Sure. I mean, it doesn't seem to do anything, so I suspect user error. The project I'm trying to build is https://github.com/xmlresolver/xmlresolvercs.

Running ./gradlew… (instead of /usr/local/bin/gradle)
Initialized native services in: /Users/ndw/.gradle/native
The client will now receive all logging from the daemon (pid: 24472). The daemon log file: /Users/ndw/.gradle/daemon/7.1/daemon-24472.out.log
Starting 19th build in daemon [uptime: 6 hrs 36 mins 13.283 secs, performance: 100%, non-heap usage: 31% of 256 MiB]
Using 16 worker leases.
Now considering [/Users/ndw/Projects/xmlresolver/cs] as hierarchies to watch
Watching the file system is enabled if available
Starting Build
Settings evaluated using settings file '/Users/ndw/Projects/xmlresolver/cs/settings.gradle'.
Projects loaded. Root project using build file '/Users/ndw/Projects/xmlresolver/cs/build.gradle'.
Included projects: [root project 'cs']

> Configure project :
Evaluating root project 'cs' using build file '/Users/ndw/Projects/xmlresolver/cs/build.gradle'.
All projects evaluated.
Selected primary task 'dotnetBuild' from project :
Start restoring packages
Starting process 'command '/usr/local/share/dotnet/dotnet''. Working directory: /Users/ndw/Projects/xmlresolver/cs Command: /usr/local/share/dotnet/dotnet restore XmlResolver/XmlResolver.sln --verbosity Normal
Successfully started process 'command '/usr/local/share/dotnet/dotnet''
Build started 8/10/2021 4:13:57 PM.
     1>Project "/Users/ndw/Projects/xmlresolver/cs/XmlResolver/XmlResolver.sln" on node 1 (Restore target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Debug|Any CPU".
       _GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         Committing restore...
         Committing restore...
         Committing restore...
         Committing restore...
         Assets file has not changed. Skipping assets file writing. Path: /Users/ndw/Projects/xmlresolver/cs/XmlResolver/UnitTests/obj/project.assets.json
         Assets file has not changed. Skipping assets file writing. Path: /Users/ndw/Projects/xmlresolver/cs/XmlResolver/XmlResolver/obj/project.assets.json
         Assets file has not changed. Skipping assets file writing. Path: /Users/ndw/Projects/xmlresolver/cs/XmlResolver/SampleApp/obj/project.assets.json
         Assets file has not changed. Skipping assets file writing. Path: /Users/ndw/Projects/xmlresolver/cs/XmlResolver/XmlResolverData/obj/project.assets.json
         Restored /Users/ndw/Projects/xmlresolver/cs/XmlResolver/XmlResolverData/XmlResolverData.csproj (in 30 ms).
         Restored /Users/ndw/Projects/xmlresolver/cs/XmlResolver/SampleApp/SampleApp.csproj (in 30 ms).
         Restored /Users/ndw/Projects/xmlresolver/cs/XmlResolver/XmlResolver/XmlResolver.csproj (in 30 ms).
         Restored /Users/ndw/Projects/xmlresolver/cs/XmlResolver/UnitTests/UnitTests.csproj (in 30 ms).

         NuGet Config files used:
             /Users/ndw/.nuget/NuGet/NuGet.Config

         Feeds used:
             https://api.nuget.org/v3/index.json
         All projects are up-to-date for restore.
     1>Done Building Project "/Users/ndw/Projects/xmlresolver/cs/XmlResolver/XmlResolver.sln" (Restore target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.68
Complete restoring packages
Start parsing project
Starting process 'command '/usr/local/share/dotnet/dotnet''. Working directory: /Users/ndw/Projects/xmlresolver/cs Command: /usr/local/share/dotnet/dotnet --version
Successfully started process 'command '/usr/local/share/dotnet/dotnet''
Use net5.0 for project parser
  Extracting parser to /Users/ndw/Projects/xmlresolver/cs/build/tmp/dotnet
Reflections took 0 ms to scan 1 urls, producing 9 keys and 9 values 
Starting process 'command '/usr/local/share/dotnet/dotnet''. Working directory: /Users/ndw/Projects/xmlresolver/cs/build/tmp/dotnet Command: /usr/local/share/dotnet/dotnet run -f net5.0 -- /Users/ndw/Projects/xmlresolver/cs/XmlResolver/XmlResolver.sln {'Configuration':'Release','Version':'3.0.1','PackageVersion':'3.0.1'}
Successfully started process 'command '/usr/local/share/dotnet/dotnet''
Complete parsing project
Tasks to be executed: [task ':dotnetBuild']
Tasks that were excluded: []
:dotnetBuild (Thread[Execution worker for ':',5,main]) started.

> Task :dotnetBuild UP-TO-DATE
Caching disabled for task ':dotnetBuild' because:
  Build cache is disabled
Skipping task ':dotnetBuild' as it is up-to-date.
:dotnetBuild (Thread[Execution worker for ':',5,main]) completed. Took 0.007 secs.

BUILD SUCCESSFUL in 5s
1 actionable task: 1 up-to-date
Watched directory hierarchies: [/Users/ndw/Projects/xmlresolver/cs]
ngyukman commented 3 years ago

it is because the task is up to date already, you probably need to run the task clean first by gradlew clean dotnetBuild --info

from the project architecture, the artifact should be inside /XmlResolver/XmlResolver/bin/Release/

btw, you might want to remove version and packageVersion as the plugin is already providing the default version based on the value in gradle.properties

ndw commented 3 years ago

Right. I do see the artifacts now, thank you! (Is it possible to change the architecture so that all the build artifacts are under build instead of "mixed in" with the sources?)

ngyukman commented 3 years ago

in that case you can update the csproj's OutputPath

you could also change the OutputPath in build.gradle by

dotnet {
    build {
        OutputPath = 'build/dotnet'
    }
}

it should inject the property to dotnet build (you can check the actual command executed with --info)