I'm trying to create a NuGet package using a Cake script:
var configuration = Argument("configuration", "Release");
var binDir = Directory("./bin") ;
var nugetPackageDir = Directory("./artifacts");
var nugetFilePaths = GetFiles("./**/*.csproj").Concat(GetFiles("./**/*.nuspec"));
var nuGetPackSettings = new NuGetPackSettings
{
BasePath = binDir + Directory(configuration),
OutputDirectory = nugetPackageDir
};
Task("NuGetPack")
.Does(() => NuGetPack(nugetFilePaths, nuGetPackSettings));
I get the following error:
========================================
NuGetPack
========================================
Executing task: NuGetPack
Attempting to build package from 'SomeProject.csproj'.
MSBuild auto-detection: using msbuild version '12.0' from 'C:\Program Files (x86)\MSBuild\12.0\bin'.
Unable to find 'C:\DEV\SomeProject\bin\Debug\SomeProject.dll'. Make sure the project has been built.
An error occured when executing task 'NuGetPack'.
Error: NuGet: Process returned an error (exit code 1).
It searches the assembly in the Debug folder instead of the Release folder.
How to set NuGetPack build configuration to Release in Cake?
You need to add the following command line argument -Prop Configuration=Release to the nuget pack command:
var nuGetPackSettings = new NuGetPackSettings
{
BasePath = binDir + Directory(configuration),
OutputDirectory = nugetPackageDir,
ArgumentCustomization = args => args.Append("-Prop Configuration=" + configuration)
};
It can be set using the Properties property:
var nuGetPackSettings = new NuGetPackSettings
{
BasePath = binDir + Directory(configuration),
OutputDirectory = nugetPackageDir,
Properties = new Dictionary<string, string>
{
{ "Configuration", configuration }
}
};
Related
Apparently, python interpreter is unable to find location of the hello_world.py script which I'm trying to run by using python.NET. I think I've set the environment variables correctly. Even though I've added the MyScripts path to the PYTHONPATH environment variable, Python.Runtime.PythonException: No module named 'hello_world' is thrown which confuses me. Could anyone please indicate what I'm missing? I will also add the python script cause I'm not sure if the problem lies there.
Versions:
python.Net 3.0.1 64-bit (Installed from NuGet using dotnet CLI)
python 3.8 64-bit
dotnet 6.0
These SO answers[1, 2] were helpful but I'm still unable to resolve my issue.
using System;
using Python.Runtime;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
string user = "user1";
var PYTHONNET_PYDLL = #$"C:\Users\{user}\AppData\Local\Programs\Python\Python38\python38.dll";
var pathToPythonnet = #$"C:\Users\{user}\AppData\Local\Programs\Python\Python38\Lib\site-packages";
var pathToScript = #$"C:\Users\{user}\MyScripts";
var pathToPython = #$"C:\Users\{user}\AppData\Local\Programs\Python\Python38\";
var paths = pathToPython + ";" + pathToPythonnet + ";" + pathToScript + ";" + Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
Environment.SetEnvironmentVariable("PYTHONNET_PYDLL", PYTHONNET_PYDLL, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("PYTHONHOME", pathToPython, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("PYTHONPATH", paths, EnvironmentVariableTarget.Process );
PythonEngine.Initialize();
using (Py.GIL())
{
dynamic np = Py.Import("numpy");
Console.WriteLine(np.cos(np.pi * 2 )); // this works
dynamic helloPy = Py.Import("hello_world"); // TODO: module not found
dynamic result = helloPy.hello_world();
Console.WriteLine($"Python says: {result}");
}
}
}
}
hello_world.py file location is C:\Users\{user}\MyScripts\hello_world.py. And the script looks like this
def hello_world():
print("script is running....")
return "Hello World!"
Error thrown on running dotnet run CLI
1.0
Unhandled exception. Python.Runtime.PythonException: No module named 'hello_world'
at Python.Runtime.PythonException.ThrowLastAsClrException()
at Python.Runtime.NewReferenceExtensions.BorrowOrThrow(NewReference& reference)
at Python.Runtime.PyModule.Import(String name)
at Python.Runtime.Py.Import(String name)
at HelloWorld.Program.Main(String[] args)
I'm trying to setup withHoogle in my default.nix, but I'm getting this error:
developPackage, error: attempt to call something which is not a function but a set(at line 26).
Here is my default.nix code:
let
pkgs = import <nixpkgs> {};
compilerVersion = "ghc865";
compiler = pkgs.haskell.packages."${compilerVersion}";
in
compiler.developPackage
{
# returnShellEnv = false;
root = ./.;
# source-overrides = {};
modifier = drv:
let pkg = pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
[
cabal-install
cabal2nix
ghcid
control
text
brick
]);
in pkg // {
env = (pkg.env { withHoogle = true; }).overrideAttrs (old: {
shellHook =
''
export PS1='\n\[\033[1;32m\][\[\e]0;nix-shell: \W\a\]nix-shell:/\W]\$ \[\033[0m\]'
'';
});
};
}
I had a similar error message when trying to nix-build a seemingly correct derivation (default.nix).
Eventually I found out using the --show-trace parameter to nix-build, that the error lie in an overlay I had in my user's ~/.config/nixpkgs/overlays directory lying around.
HTH
I am writing a cordova plugin with a node hook to run after_prepare .
This is for Android only.
From within this hook I need to get the cordova package name, so I can copy a file to the src/com/example/myproject folder (if the package is com.example.myproject).
If I know the package name I can make this path. I have it working hardcoded now but I need this to work with two different package names.
Is there a way to get the package name from within this code in the plugin hook?
module.exports = function(ctx){
var fs = ctx.requireCordovaModule('fs');
var path = ctx.requireCordovaModule('path');
var deferral = ctx.requireCordovaModule('q').defer();
//get package name here
//do other stuff
}
I have done a lot of research but have not been able to find this.
Thanks.
It doesn't look like it is available off of the context object, but you could try to parse the config.xml.
module.exports = function(context) {
var fs = require('fs');
var path = require('path');
var config_xml = path.join(context.opts.projectRoot, 'config.xml');
var et = context.requireCordovaModule('elementtree');
var data = fs.readFileSync(config_xml).toString();
var etree = et.parse(data);
console.log(etree.getroot().attrib.id);
};
The local-webserver plugin uses a similar strategy for reading config properties.
Here my compilation from different answers that works in 2021.
I use it to update some parameters in Xcode project for plugins compilation.
You can see that I am getting here app id and name from config.xml
And you can add it to after_prepare hook:
<hook src="scripts/addBuildSettingsToXcode.js" type="after_prepare" />
#!/usr/bin/env node
let fs = require('fs');
let xcode = require('xcode');
let path = require('path');
let et = require('elementtree');
module.exports = function (context) {
//console.log(context);
function addBuildPropertyToDebugAndRelease(prop, value) {
console.log('Xcode Adding ' + prop + '=' + value);
myProj.addBuildProperty(prop, value, 'Debug');
myProj.addBuildProperty(prop, value, 'Release');
}
function updateBuildPropertyToDebugAndRelease(prop, value) {
console.log('Xcode Updating ' + prop + '=' + value );
myProj.updateBuildProperty(prop, value, 'Debug');
myProj.updateBuildProperty(prop, value, 'Release');
}
// Getting app id and name from config.xml
let config_xml = path.join(context.opts.projectRoot, 'config.xml');
let data = fs.readFileSync(config_xml).toString();
let etree = et.parse(data);
let appId = etree.getroot().attrib.id ;
let appName = etree.getroot().find('name')['text'];
// Building project path
let projectPath = 'platforms/ios/' + appName + '.xcodeproj/project.pbxproj';
// Opening Xcode project and parsing it
myProj = xcode.project(projectPath);
myProj = myProj.parseSync();
// Common properties
addBuildPropertyToDebugAndRelease('DEVELOPMENT_TEAM', 'CGXXXXXXX');
addBuildPropertyToDebugAndRelease('CODE_SIGN_IDENTITY', '"Apple Development"');
// Compilation properties
addBuildPropertyToDebugAndRelease('ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES', 'YES');
// Save project file
fs.writeFileSync(projectPath, myProj.writeSync());
};
Basically I'm looking for a Gulp plugin to turn a directory like this:
/app
- htmlfile1.html
- htmlfile2.html
- htmlfile3.html
- /css
-cssmain.css
-/js
-global.js
And turn that into this:
/dist
-/htmlfile1
- htmlfile1.html
- /css
-cssmain.css
-/js
-global.js
- /htmlfile2
- htmlfile2.html
- /css
-cssmain.css
-/js
-global.js
- /htmlfile3
- htmlfile3.html
- /css
-cssmain.css
-/js
-global.js
Any thoughts on how to do accomplish a build system like this?
The code allows common files to be added to every page distribution as well as unique dependencies defined as an array in the pages object.
The following Gulp file relies on gulp-foreach, parse-filepath, and event-stream: npm install gulp gulp-foreach parse-filepath event-stream --save-dev
gulpfile.js:
// Command:
// npm install gulp gulp-foreach parse-filepath event-stream --save-dev
// Include gulp
var gulp = require('gulp');
var foreach = require('gulp-foreach'); // https://www.npmjs.org/package/gulp-foreach
var parsePath = require('parse-filepath'); // https://www.npmjs.org/package/parse-filepath
var es = require('event-stream'); // https://www.npmjs.org/package/event-stream
// The pages that each make a distribution
// Unique dependencies are defined as an array value for each page.
var pages = {
'./app/htmlfile1.html': [
'./app/images/1.png',
'./app/images/1-another.png',
],
'./app/htmlfile2.html': [],
'./app/htmlfile3.html': []
};
// Files added to each page distribution
var common = [
'./app/css/cssmain.css',
'./app/js/global.js',
];
function makeDistributionStream(page)
{
var gulpStream = gulp.src(page)
.pipe(foreach(function(stream, file) {
var pathParts = parsePath(file.path);
// Assemble the distribution path
var destinationPath = './dist/' + pathParts.name + '/';
// Pipe the html into the distribution folder
stream.pipe(gulp.dest(destinationPath));
// Move all of the unique and common files into the distibution
var uniqueDependencies = pages[page];
// Merge the common files to the unique ones
var distFiles = uniqueDependencies.concat(common);
gulp.src(distFiles, {base: './app/'})
.pipe(gulp.dest(destinationPath));
}));
return gulpStream;
}
// Assemble the distribution directories for each page
gulp.task('make-distributions', function() {
var mergedStream = null;
for(var page in pages)
{
var stream = makeDistributionStream(page);
// Merge the streams, if there is already one
if(mergedStream)
{
mergedStream = es.merge(mergedStream, stream);
}
// Otherwise, just make it this one
else
{
mergedStream = stream;
}
}
return mergedStream;
});
// Rerun the task when a file changes
gulp.task('watch', function() {
// If the html pages change, re-make the distributions
gulp.watch(Object.keys(pages), ['make-distributions']);
});
// Default Task
gulp.task('default', ['make-distributions', 'watch']);
I am compiling my require.js based JavaScript together with r.js. We use the css plugin. Here is my build.js that I am running:
var requirejs = require('requirejs');
var sys = require("sys");
var prop = require("./node/config.js");
var extend = require('node.extend');
var baseNoC=prop.base.replace("C:/","");
window = {
top: {
M4_CONFIG: {
path: prop.base + "/uif/trunk"
}
}
};
var amdConfig = require(prop.base + "/uif/trunk/scripts/bootstrap/amd-config");
var config = {
baseUrl: "C:",
name: "/"+baseNoC+"/uif/trunk/scripts/bootstrap/home-main.js",
out: "main-built.js",
optimize: "none",
map: {
'*': {
'css': baseNoC + "/vendor/trunk/require-plugins/require-css/0.0.3/css"
}
}
};
config = extend(config, amdConfig);
config.paths["all-files"]= window.top.M4_CONFIG.path + "/all-files";
//I tried it with this line in and out.
//config.paths["css"]="Projects/mercury/vendor/trunk/require-plugins/require-css/0.0.3/css";
requirejs.optimize(config, function(buildResponse) {
//buildResponse is just a text output of the modules
//included. Load the built file for the contents.
//Use config.out to get the optimized file contents.
var contents = fs.readFileSync(config.out, 'utf8');
}, function(err) {
//optimization err callback
sys.puts("error! " + err);
});
When I run my page with my generated JavaScript, I get "NetworkError: 404 Not Found - [domain]/css.js"
The location of the file is in the location specified on my config.map. Anyway, I don't understand why it isn't in my compiled JavaScript. What should I do?
P.S.
We're using Sass and I wouldn't mind just packaging up one big css with Sass and telling it to ignore the !css in the code. (However, those are in there for historical reasons.)
The issue is a bug in the r.js compiler, where it is ignoring the map config. I was just bitten by the same issue. I'm working on getting it resolved.