Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Migrating the project.json file to the new .csproj breaks the Sub Generators #849

Closed
k1l3s opened this issue Nov 24, 2016 · 2 comments
Closed

Comments

@k1l3s
Copy link

k1l3s commented Nov 24, 2016

Short issue description

Migrating the project.json to the new .csproj format throws an error using the subgenerators.

Expected behavior

"yo aspnet:class Filename" should create the expected class

Actual behavior

"yo aspnet:class Filename" actually throws an "events.js:160 throw er; // Unhandled 'error' event"

Steps to reproduce the behavior

-Install Asp.net core 1.1.
-Use the aspnet-generator to create a ASP.net basic template.
-Run the "dotnet migrate" command to migrate to .csproj.
-Run "dotnet restore"
-Run "yo aspnet:class NewClass"

That should throw the error


OS version (Win/Mac/*Nix?)

Windows 10

NodeJS version

node --version

v6.6.0

Yeoman version

yo --version

1.8.5

Generator version

NPM 3.*:

npm list -g generator-aspnet

generator-aspnet@0.2.5

Notes

I think the error is caused by the file configuration.js. This file is made to find up a hardcoded 'project.json' inside the project, how this file does not exist anymore the baseDirectory var should be null. (Maybe could be done to support both cdproj and json???)

  // Get the namespace relative to the cwd
  getNamespace: function(fs) {
    'use strict';

    var baseNamespace = getBaseNamespace(fs);
    var cwd = process.cwd();
    var baseDirectory = path.resolve(path.dirname(this.getProjectCsprojPath()));
    var relativePath = path.relative(baseDirectory, cwd);
    if (relativePath) {
      return [baseNamespace].concat(relativePath.split(path.sep)).join('.');
    }

    return baseNamespace;
  },
  getProjectJsonPath: function() {
    'use strict';

    return findup('project.json');
  },
  getProjectJson: function(fs) {
    'use strict';

    var path = module.exports.getProjectJsonPath();
    if (!path) {
      return {};
    }

    return fs.readJSON(path, {});
  },
  getGlobalJsonPath: function() {
    'use strict';

    return findup('global.json');
  },
  getGlobalJson: function(fs) {
    'use strict';

    var path = module.exports.getGlobalJsonPath(path);
    if (!path) {
      return {};
    }

    return fs.readJSON(path, {});
  },
};
@peterblazejewicz
Copy link
Member

That's unlikely to be fixed before (if at all) migration is done this one:
#846

@sayedihashimi
Copy link
Member

We are shutting this repo down, it's been replaced with dotnet new.

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

3 participants