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

Allow building of solutions #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ plugins:
- serverless-dotnet
```

And that's all there is to it. From this point, `dotnet restore` and `dotnet publish` will run as part of each `serverless deploy` run and the output will be zipped into the `.serverless` folder of your service, as it would for other runtimes.
If your `.cs` files are in your service's root folder, then that's all there is to it. From this point, `dotnet restore` and `dotnet publish` will run as part of each `serverless deploy` run and the output will be zipped into the `.serverless` folder of your service, as it would for other runtimes.

If your files are contained in a solution or some other subfolder, then you just need to point to the project folder in the `custom` section of your config file (YAML shown):

```yaml
custom:
dotnet:
slndir: relative/path/to/project/folder
```

## Note
If you are using the `aws-csharp` service template, you will need to remove the following line from your `serverless.yml` file as these are not needed any more:
Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const BbPromise = require('bluebird');
const clean = require('./lib/clean');
const compile = require('./lib/compile');
const pack = require('./lib/pack');
const path = require('path');

class ServerlessDotNet {
constructor(serverless, options) {
Expand All @@ -18,6 +19,12 @@ class ServerlessDotNet {
pack
);

this.servicePath = this.serverless.config.servicePath;
this.customVars = this.serverless.variables.service.custom;
if ((this.customVars) && (this.customVars.dotnet) && (this.customVars.dotnet.slndir)) {
this.servicePath = path.join(this.serverless.config.servicePath, this.customVars.dotnet.slndir);
}

this.hooks = {
'before:deploy:createDeploymentArtifacts': () => BbPromise.bind(this)
.then(this.clean)
Expand All @@ -28,4 +35,4 @@ class ServerlessDotNet {
}
}

module.exports = ServerlessDotNet;
module.exports = ServerlessDotNet;
4 changes: 2 additions & 2 deletions lib/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = {
this.serverless.cli.log('Serverless DotNet: Clean');

let cleanupPaths = [
path.join(this.serverless.config.servicePath,'bin'),
path.join(this.serverless.config.servicePath,'obj')
path.join(this.servicePath,'bin'),
path.join(this.servicePath,'obj')
];

return new BbPromise(function (resolve, reject) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const program = require('child_process');

module.exports = {
compile() {
let servicePath = this.serverless.config.servicePath;
let servicePath = this.servicePath;
this.serverless.cli.log('Serverless DotNet: Compile');

return new BbPromise(function (resolve, reject) {
Expand Down
4 changes: 2 additions & 2 deletions lib/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ module.exports = {
this.serverless.cli.log('Serverless DotNet: Pack');

const patterns = ['**'];
let servicePath = this.serverless.config.servicePath;
let servicePath = this.servicePath;
let zipFileName = `${this.serverless.service.service}.zip`;

const artifactFilePath = path.join(
servicePath,
this.serverless.config.servicePath,
'.serverless',
zipFileName
);
Expand Down