AaronBastian
AaronBastian

Reputation: 307

dotnet core dotnet build ignores changes

I have a dotnet core class library that I have successfully been able to build using the dotnet cli "dotnet build --configuration Release". This is important because I am also building this project in Jenkins on a Linux server.

Recently, I needed to go in and make some modifications to the project. When building it again with "dotnet build --configuration Release", it built, but none of my changes and additions were present. Please note that it behaves consistently (successfully and unsuccessfully) between the Jenkins environment in Linux and my Windows 10 command prompt when using "dotnet build --configuration Release".

If I build with Visual Studio 2015 (which I assume uses MSBuild), all changes are then present after I build the class library, and all is right with the world.

I assume that there is something wrong with my project.json?

{
  "version": "1.0.0.*",

  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Dapper": "1.50.2",
    "Dapper.Mapper": "1.50.1"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  }
}

Upvotes: 2

Views: 1613

Answers (3)

Hayrullah Cansu
Hayrullah Cansu

Reputation: 262

If dependencies or libraries have been changed, old files affect the packaging operation.

  1. Remove obj and bin folders from project.
  2. Run dotnet restore
  3. Run dotnet build --configuration Release

Upvotes: 0

AaronBastian
AaronBastian

Reputation: 307

So it turns out that the root cause of this issue was simply that I had structured my solution incorrectly and did not have a gobal.json file referencing the project. I am not entirely sure WHICH fixed it, or WHY it fixed it, but my class library solution needs the following: global.json in the SolutionItems folder src folder - Project in the src folder - Unit Tests in the src folder

Next, the issue with the linux server is that its nuget push command didn't recognize the dotnet core Version string. This is resolved in nuget cli version 3.5.0, but that version is not yet supported for Linux. As a temporary backup, I created the same job on a Windows based machine running Jenkins and nuget cli version 3.5.0, and it all works flawlessly.

When the next version of dotnet core comes out, and has a dotnet nuget push command, I am sure that I can revisit the Linux server.

Then the commands that I run in Jenkins are dotnet restore dotnet pack --configuration Release --versionsuffux %BUILD_NUMBER% nuget push PackageName ApiKey -Source http://NugetSource

Upvotes: 1

Stephane Duteriez
Stephane Duteriez

Reputation: 934

You probably did it, but did you restart the service in linux?

Upvotes: 0

Related Questions