Run `flutter clean` command on each project in a directory - windows

As a Flutter developer, I've been working on many projects. I have to work on all of them occasionally. Now those projects lie in a single directory occupying 30+ GB on my drive. It'd be a good idea to have the project's build-cache deleted to save some space. So I figured to write a script that would loop through each of them and run flutter clean inside every folder instead of running the command manually under each project's root.
After Google and StackOverflow search I came up with a command :
for /D %G in ("D:\MyProjects\*") do flutter clean "%~fG"
Well this command executes the flutter clean command for each folder like:
C:\Users\vipin>flutter clean "D:\MyProjects\Project1"
C:\Users\vipin>flutter clean "D:\MyProjects\Project2"
C:\Users\vipin>flutter clean "D:\MyProjects\Project3"
C:\Users\vipin>flutter clean "D:\MyProjects\Project4"
This should have worked since the command states to run flutter clean for each folder as it looked. Unfortunately, it didn't and threw error:
C:\Users\vipin>flutter clean "D:\MyProjects\Project1"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:\Users\vipin>flutter clean "D:\MyProjects\Project2"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:\Users\vipin>flutter clean "D:\MyProjects\Project3"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:\Users\vipin>flutter clean "D:\MyProjects\Project4"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
...
Well, the pubspec.yaml files are very much present in each folder and I figured that the flutter clean command demands your prompt pointing to Project's ROOT, like below to do the job:
D:\Myprojects\Project1>flutter clean
Now I'm looking for a command/script anything to move the command's prompt to each project's root and execute the command.

Glad you asked. I had the same thought about doing it to my list of projects. The below command will do exactly what you expect. Make sure to run this from D:\MyProjects
for /d %i in (D:\MyProjects\*) do ( cd "%i" & flutter clean )

Related

how to build go outside of source directory?

My go application directory structure is like this:
/app
go.mod
go.sum
main.go
When I build the app I usually cd into that directory and build.
cd app
go build
I wonder if I can build without cd in to app directory.
When I go go build /app, it prints go: go.mod file not found in current directory or any parent directory; see 'go help modules'.
See https://golang.org/ref/mod#commands-outside :
go build needs to be run from a module directory.
The simplest way is to cd into your module directory (cd /app) to run your go build command.
(there probably is some way to create a phony local go.mod file, and reference your /app module from there, but I wasn't able to devise a hack to do this)
Go now can change directory before build with the help of flag -C:
go build -C app
"The go subcommands now accept -C to change directory to before performing the command"
Source: https://tip.golang.org/doc/go1.20
(You don't need to run cd .. after this command. Shell stays in the same directory)
I'm pretty sure to build you will need to be in the app directory.
As a workaround if you are just wanting to be on the command line in a different directory and want to run the build with one command you can just chain the cd and go build commands together like this:
cd app; go build ; cd ..
This is the same amount of typing but could be in your command history just a couple presses of the up arrow away.
Note this is for bash or similar UNIX style shell. If using Windows cmd then I think it would be something like this (Not tested as I don’t have readily available access to a Windows machine right now):
cd app & go build & cd ..

Flutter pub get running in wrong directory?

I created a new flutter project using flutter create. The path to pubspec.yaml is D:\dev\flutter\example\
But when I run flutter run in my projects, it gives an error: pubspec.yaml not found in D:\dev\flutter\
Why is flutter pub get running in the parent directory of my project?
I solved it. my bad i didnt look at my pubspec which contained
dependencies:
flutter:
sdk: flutter
responsive_framework:
path: ../
the 'path' was causing it to run pub get in parent directory.
Move to the folder you have recently created-
cd example
Then run "flutter run" from that folder.
Go to your project directory by:
cd D:\dev\flutter\example
Then run:
flutter clean
flutter run

Cannot copy long path files in Windows 10 within Dockerfile COPY

I build an image from a base image. In the Dockerfile of the base image I run a command ONBUILD COPY . /workspace. When I build my image from this base image then it copy all the files from current directory to the /workspace directory of the result image.
Then I run mvn clean install from the Dockerfile with an error: cannot find symbol. The problem is that all the .java files that has long path names are not copied from current directory to the /workspace directory and so the error.
I tried to activate long pathns in Local Computer Policy, I also checked it in the registry, but it does't helped. I tried to run CMD as Administrator and then also tried to build from Git Bash command line, none fixed the problem.
Does anyone knows what could be the problem and how to resolve it?

Not able to build ROS package with catkin_make. Confused by package tree

I'm looking to run the main.launch stored in vehicle/launch/ from this github page
https://github.com/aureliopuebla/vehicle
I am very new at using ROS and have been learning, however I can't seem to be able to build these files.
If I try to use catkin_make on the parent folder it says that there is no existing 'src' folder.
If I go into the /vehicle folder there is a 'src' folder, but if I try to run catkin_make there, then it says that I have to run it at the root of the workspace. Which has me a bit stumped.
I have also tried to just run 'cmake ..', then 'make', and then 'sudo make install' in the /vehicle folder, but that just fills the /vehicle folder with copies of the other folders in the parent folder.
The reason why I want to build these packages is to be able to run the 'main.launch' file inside the '/vehicle/launch' folder with roslaunch, but it keeps saying that it can't find the other packages, no matter what I do.
Ready to clear up any questions. Thanks for the help.
the CMakeLists.txt in the folder is the top-level CMakeLists. So You need to make this src folder yourself.
Just do the following:
$ mkdir -p vehicle_ws && cd vehicle_ws
$ git clone https://github.com/aureliopuebla/vehicle.git
$ mv vehicle src
$ catkin_make
This way it should work. Just leave out mkdir -p vehicle_ws, if you already created a workspace and instead just cd into it.

xcodebuild - how to specify the directory where the project is, without doing a cd in it

I am using xcodebuild from command line in a script, but I realized that I cannot specify the path of the project that i wanna build;I am forced to cd in the folder where the project is.
Is there a way to accomplish the build process without having to cd in the directory, or this is how it must be?
Is not a big deal to cd into the directory and execute xcodebuild, but I wonder what if someday you need to build a project and you cannot cd into the directory....It doesn't really make sense to me to not being able to specify the path.
You can use xcodebuild -project pathtoprojectfile
eg
xcodebuild -project /IOSprojects/YourProject/YourProject.xcodeproj
You must be in the directory containing the project(s) when you run xcodebuild. If you don’t want to mess with your current directory, there a couple of options:
/bin/sh -c "cd $PRJDIR; xcodebuild"
or
(cd $PRJDIR; xcodebuild)

Resources