Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Dotnet watch doesn't run with certain references #136

Closed
janpieterz opened this issue Jul 12, 2016 · 13 comments
Closed

Dotnet watch doesn't run with certain references #136

janpieterz opened this issue Jul 12, 2016 · 13 comments

Comments

@janpieterz
Copy link

janpieterz commented Jul 12, 2016

I have been unable to pinpoint exactly which is erroring, but it seems to be related to certain project references. dotnet run works fine, and I have tried all kinds of things with the references projects, lock files, restores and what not. Reason I'm thinking this is a referencing issue is because in other projects it works fine that have less or different references (local project references). It fails reliably every time ;)

Error given:

[DotNetWatcher] fail: Error(s) reading project file 'C:\Development\***\Portal\project.json':
[DotNetWatcher] fail: Value cannot be null.
Parameter name: path2
[DotNetWatcher] info: Fix the error to continue.

Project.Json:

{
  "userSecretsId": "aspnet-Portal-dbc56205-faad-485b-b721-9f61800808d8",

  "dependencies": {
    "Halibut": "2.2.2",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Newtonsoft.Json": "9.0.1",
    "NServiceBus": "5.2.14",
    "NServiceBus.Azure.Transports.WindowsAzureServiceBus": "6.4.0",
    "NServiceBus.Serilog": "2.0.1.1",
    "WindowsAzure.ServiceBus": "2.7.6",
    "WindowsAzure.Storage": "4.3.0",
    "Autofac": "4.0.0-rc3-286",
    "Autofac.Extensions.DependencyInjection": "4.0.0-rc3-280",
    "Serilog.Extensions.Logging": "1.0.0",
    "Serilog.Sinks.ColoredConsole": "2.0.0",
    "Serilog.Sinks.Seq": "2.0.0"
  },

  "tools": {
    "Microsoft.DotNet.Watcher.Tools": {
      "version": "1.0.0-preview2-final"
    }
  },

  "frameworks": {
    "net451": {
      "imports": [
        "dotnet5.6",
        "netcoreapp1.0",
        "dnxcore50",
        "portable-net45+win8"
      ],
      "dependencies": {
        "***": {
          "target": "project"
        },
        "***": {
          "target": "project"
        },
        "Messages": {
          "target": "project"
        },
        "Services.Billing": {
          "target": "project"
        },
        "Services.Client": {
          "target": "project"
        },
        "Services.ITops.Sms": {
          "target": "project"
        },
        "Services.Message": {
          "target": "project"
        },
        "Services.Phone": {
          "target": "project"
        },
        "Services.User": {
          "target": "project"
        }
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config",
      "***.nuspec",
      "Resources"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp productifyscripts", "gulp vendorScripts", "gulp appStyles", "gulp vendorStyles" ] 
  }
}

@victorhurdugaci
Copy link
Contributor

Can you dotnet run with that project.json ?

@janpieterz
Copy link
Author

janpieterz commented Jul 12, 2016

Jup, that's the odd bit. See logs:

C:\Development\***\Portal>dotnet watch run
[DotNetWatcher] fail: Error(s) reading project file 'C:\Development\***\Portal\project.json':
[DotNetWatcher] fail: Value cannot be null.
Parameter name: path2
[DotNetWatcher] info: Fix the error to continue.
[--] Had to ctrl-c here
C:\Development\***\Portal>dotnet run
Project Portal (.NETFramework,Version=v4.5.1) was previously compiled. Skipping compilation.
2016-07-12 18:43:01.754 INFO  DefaultFactory Logging to 'C:\Development\***\Portal\bin\Debug\net451\win7-x64\' with level Info
[--] **snip** all kinds of bootstrapping logging of NServiceBus etc.
2016-07-12 18:44:48 ("Microsoft.AspNetCore.Hosting.Internal.WebHost") [Debug] Hosting starting
2016-07-12 18:44:48 ("Microsoft.AspNetCore.Hosting.Internal.WebHost") [Debug] Hosting started
Hosting environment: Production
Content root path: C:\Development\***\Portal
Now listening on: http://localhost:5000

@victorhurdugaci
Copy link
Contributor

What dotnet version do you use? (dotnet --version)

@janpieterz
Copy link
Author

1.0.0-preview2-003121

@victorhurdugaci
Copy link
Contributor

Dank je wel :) The project and everything looks fine. I'll try to reproduce here with your project later today. I'll keep you updated.

@janpieterz
Copy link
Author

janpieterz commented Jul 12, 2016

Alsjeblieft 😉
I'll probably be able to try and get something together myself tomorrow afternoon that replicates it!

Just a thought, it could be related to the fact that running dotnet restore doesn't work on command line (Unable to resolve all those custom libraries), while the restore from Visual Studio (which uses a restore.dg file) works, where the full paths towards the csproj are maintained?

Just for your info, the restore.dg file which also shows the folder/csproj structure:

#:C:\Development\***\Portal\Portal.xproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\***\***.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Dependencies\***\***.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Messages\Messages.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Services.Billing\Services.Billing.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Services.Client\Services.Client.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Services.ITops.Sms\Services.ITops.Sms.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Services.Message\Services.Message.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Services.Phone\Services.Phone.csproj
C:\Development\***\Portal\Portal.xproj|C:\Development\***\Services.User\Services.User.csproj
C:\Development\***\***\***.csproj|C:\Development\***\Dependencies\***\***.csproj
C:\Development\***\Services.Billing\Services.Billing.csproj|C:\Development\***\Dependencies\***.csproj
C:\Development\***\Services.Client\Services.Client.csproj|C:\Development\***\ClientContracts\ClientContracts.csproj
C:\Development\***\Services.Client\Services.Client.csproj|C:\Development\***\Dependencies\***\***.csproj
C:\Development\***\Services.ITops.Sms\Services.ITops.Sms.csproj|C:\Development\***\Dependencies\***\***.csproj
C:\Development\***\Services.Message\Services.Message.csproj|C:\Development\***\Dependencies\***\***.csproj
C:\Development\***\Services.Phone\Services.Phone.csproj|C:\Development\***\Dependencies\***\***.csproj
C:\Development\***\Services.User\Services.User.csproj|C:\Development\***\Dependencies\***\***.csproj

@victorhurdugaci
Copy link
Contributor

Ohhhh that might explain a lot. I don't think there was a lot of testing with xproj -> csproj reference and dotnet watch. I'll see what I find

@janpieterz
Copy link
Author

I got it replicated. Locally this commit shows exactly the same behavior as above.
https://github.com/janpieterz/DotnetWatchError/tree/6938fc2fb97a319ebcdc77fab7e17bd0e6ece96b

@victorhurdugaci victorhurdugaci self-assigned this Jul 13, 2016
@victorhurdugaci
Copy link
Contributor

Indeed, it seems to be a problem with csproj files. We'll fix it

@victorhurdugaci
Copy link
Contributor

Pushed a PR to fix this. Unfortunately, dotnet watch will not support csproj. It will be able to run the application and restart when code files change in the xproj projects but the code in csproj will not trigger a restart.

@janpieterz
Copy link
Author

@victorhurdugaci super, thanks! Is the not-monitoring csprojs going to change when .net core moves back to csproj? And is this going to land in the August release (https://blogs.msdn.microsoft.com/dotnet/2016/07/15/net-core-roadmap/)?

On a slightly different note, do tools like this (by the asp.net team) actually follow the normal release schedule, or could a release be cut whenever the tool itself is on a next version, according to the maintainers?

@danroth27 danroth27 modified the milestones: 1.1.0-preview1, 1.0.0-preview3 Oct 24, 2016
@lakartoza
Copy link

Hi, just wanted to check in. Does .csproj still not support dotnet watch? I'm running into trouble like @janpieterz above. dotnet run works fine but for the life of me i can't get dotnet watch run to go. It just died with unexpected error

@natemcmaster
Copy link
Contributor

Does .csproj still not support dotnet watch?

We have a preview available. Install 1.0.0-msbuild3-final.

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild3-final" />
  </ItemGroup>

FYI any version labeled "preview" is a project.json-only version. We realize this is goofy, but it's temporary. When we release the 1.0.0 version in March along with VS 2017, it won't support project.json.

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

No branches or pull requests

6 participants