vscode omnisharp not working for solution but works for project - visual-studio-code

I have folders structured like this: project/csproj A, project/csproj B
If I open in vs code project dir, omnisharp works for csproj B only. If I open in vs code project/csproj A directory, omnisharp works for this project.
How fix that so I can open project directory and have working omnisharp for both projects?
Broken project is nunit type if that matters. I tried reloading vscode, disabling/enabling omnisharp.
I created project in empty directory with
dotnet new nunit -n=projectB

A solution is specified by a sln file, if you don't have one yet, just create a new one in the solution-level folder
dotnet new sln
And then, you must add the project references to the solution
dotnet sln path/to/solution add path/to/project
And if the omnisharp does not update it, restart it or vs code.
Omnisharp can only support a single project or solution, therefore, to support multiple projects, you must use "solution", which is not just a folder but with a sln file.
Your folder structure is antipattern and not naturally supported, because .NET Core uses SDK-style csproj project, which adds all source files in the project-level folder (which is where the csproj file is), so having multiple csproj files inside one project-level folder is just for one project with multiple targetings. If your project A and B is in the same folder, it means they may contain duplicate source files that may cause errors on conflict of types, unless you specified source exclusion respectively in the csproj files.
The recommanded folder structure is
<Solution and git repository level folder>
|-- src
| |-- <Project level folders>
| | |-- <Folder structures based on namespace>
| | | └-- <Source files>
| | |-- <Asset files with approprate folder structure>
| | └-- <The csproj file>
| |-- Directory.Build.props (Common MSBuild props for all src projects)
| └-- Directory.Build.targets (Common MSBuild targets for all src projects)
|-- test
|-- └-- <Test projects with similar folder structure to src>
|-- build
|-- └-- <Common MSBuild props and targets files to be referenced by src and test>
|-- docs
| └-- <Documents>
|-- <Other repository assets>
└-- <The sln file>

Related

Azure Pipeline Release Artefact linked ARM templates

We have our ARM templates in a build folder alongside our code. In our pipeline we publish our build folder as an artefact. We have master templates.
We want to run our ARM templates from a Release Pipeline, however our master templates can't find our linked templates, we get the following errors:
##[error]InvalidTemplateSpec: The relative path 'arm-kv/1.0.0.0/azuredeploy.json' could not be resolved. Please ensure the parent deployment references either an external URI or a template spec ID. The relativePath property cannot be used when creating a template deployment with a local file.
The folder structure of the created artefact is as follows;
Builds/
+-- ARM/
+-- parameters/
| +-- azuredeploy-rg-parameters.json ## parameters file
|
+-- arm-kv
| +-- 1.0.0.0/
| +-- azuredeploy.json ##(linked key vault template)
|
|- arm-storage
| +-- 1.0.0.0/
| +-- azuredeploy.json ##(linked storage template)
|
+-- azuredeploy-rg.json ##(main template)
What is the correct syntax for referencing the subfolder/templates? We've tried
arm-kv/1.0.0.0/azuredeploy.json (relative path)
./arm-kv/1.0.0.0/azuredeploy.json
/builds/arm/arm-kv/1.0.0.0/azuredeploy.json (the full artefact path)
When you run the task you are probably in the $(System.DefaultWorkingDirectory) context. This is the folder where artifacts are downloaded. Please check what you have exacelty there by adding a step and listing files.
Once you have it change your working directory for your ARM deployment step to $(System.DefaultWorkingDirectory)/builds/arm (it could be slightly different and this is why former step is needed to verify the path). Once you set it correctly you will get azuredeploy-rg.json in the root and all linked templates will become discoverable.

Eclipse 2020-09 (4.17.0) on OS X 10.13 keeps wanting me to put .gitignore and .DS_store on the path

I just upgraded to Eclipse 2020-09 (4.17.0) on OS X 10.13.
I have a large existing repository of java projects and I've installed the javascript and GWT plugins for Eclipse.
The problem is this: whenever I do almost anything (ex. save a file I'm working on), I get an error:
An error has occurred. See error log for more details. Path must include project and resource name: /.gitignore
specifically, the error comes from jface:
Problems occurred when invoking code from plug-in: "org.eclipse.jface".
the top of the error code is:
java.lang.IllegalArgumentException: Path must include project and resource name: /.gitignore
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:66)
at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2128)
at org.eclipse.core.internal.resources.Container.getFile(Container.java:196)
at org.eclipse.egit.ui.internal.staging.StagingViewContentProvider.getFile(StagingViewContentProvider.java:139)
at org.eclipse.egit.ui.internal.staging.StagingEntry.getFile(StagingEntry.java:213)
at org.eclipse.egit.ui.internal.staging.StagingEntry.getProblemSeverity(StagingEntry.java:244)
at org.eclipse.egit.ui.internal.decorators.ProblemLabelDecorator.decorateImage(ProblemLabelDecorator.java:84)
at org.eclipse.jface.viewers.DecoratingLabelProvider.getImage(DecoratingLabelProvider.java:101)
But, there's a .gitignore in both the repo root and the project root and the project path settings are:
PARENT_LOC /Users/brian/git/JavaCodeFromSVN
PROJECT_LOC /Users/brian/git/JavaCodeFromSVN/jsAipotu
WORKSPACE_LOC /Users/brian/git/JavaCodeFromSVN
So I can't figure out what the problem is or how to fix it.
I can work in eclipse but it's really annoying to get these messages all the time.
I'm sure it's something obvious but I'm just not seeing it.
Might anyone be able to help? It seems that every time I upgrade Eclipse, it's a headache of one kind or another. Perhaps, someday, I'll learn my lesson and not upgrade :(
thanks
Brian
I think I may have fixed the problem. Here's what I did that made this go away.
Right-click the project: Team -> advanced -> Clean... and let it clean all it found (lots of .gitignores etc)
At that point, I was getting warnings about .DS_Store pretty consistently.
I followed the directions at https://intellipaat.com/community/9089/how-can-i-remove-dsstore-files-from-a-git-repository-gitignore-dsstore (By Debashis Borgohain)
they are:
Remove existing .DS_Store files from the repo. In the top level repo directory:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
Create or update the .gitignore file at the top of the repo to contain a listing for .DS_Store. WHen set like this, even if Mac OS re-creates the .DS_Store files, they will be ignored by git when you commit changes, etc. Here is one way:
echo .DS_Store >> .gitignore
Commit the revised .gitignore
git add .gitignore
git commit -m '.DS_Store banished!'
to get rid of all the .DS_Store files, tell git to ignore them, and now it seems happy.
I got this error because I have a Maven project with sub-projects, and I made my Maven (base) project folder equal to the workspace folder:
📁 eclipse-workspace = maven base project folder = root of Git repo
+-- 📁 subproject_1
| +-- 📝 pom.xml (of subproject)
+-- 📁 subproject_2
| +-- 📝 pom.xml (of subproject)
+-- 📝 pom.xml (of base project)
The first error was, that the base project could not be imported as a project. I thought this was meaningless, since the base project doesn’t contain code in my case, it is only a container. However, it seems Eclipse requires the base project to be a folder in the workspace:
📁 eclipse-workspace
+-- 📁 project (base project) = root of Git repo
+-- 📁 subproject_1
| +-- 📝 pom.xml (of subproject)
+-- 📁 subproject_2
| +-- 📝 pom.xml (of subproject)
+-- 📝 pom.xml (of base project)

agignore not respecting nested forlder

my directory structure is like this:
roo
|
node_modules
|
packages
|
project1
|
lib
node_modules
project2
|
build
node_modules
I want to exclude lib, build or node_modules no matter where they are in the directory structure.
Here is my .gitignore
# dependencies
node_modules
/node_modules/
# testing
/coverage
# production
/build
/lib
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.tern-port
packages/*/lib/*
packages/*/dist/*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log
packages/*/node_modules
packages/*/lib
packages/*/build
Two options:
Use an .ignore file, and add the following to skip lib and node_moduels (for example):
*node_modules/
*lib/
Use the command line option to ignore a directory, the "--ignore-dir." For example, if you want to ignore node_modules and lib, you'd use this:
ag --ignore-dir lib --ignore-dir node_modules value
Note: I tested this with your exact directory structure.

How to do gradle build on nested projects

I am trying to build the java projects with gradle and my project structure something like below:
Root
|
|----Child
| |
| Child1 (build.gradle)
|
|
|----Child12
| |
| Child111
| |
| Child222(build.gradle)
|
settings.gradle
As you can see, the project structure, here I am doing the gradle eclipse build for all the projects (Child1, Child222) in a single attempt by modifying settings.gradle and including the child projects something like below:
include 'Child/Child1'
include 'Child12/Child111/Child222'
Build is fine with that.
Whereas, while importing the projects(Child1, Child222) into eclipse, I am getting the following error:
Creation Problems
Path for project must have only one segment.
Because, in the Child1 .project file
<projectDescription>
<name>Root/Child1</name>
<projectDescription>
project name appearing as Root/Child1, instead of Child1.
Is there anyway, with that I can import the projects into the eclipse?
I got it, I changed settings.gradle file like below:
include 'Child:Child1'
include 'Child12:Child111:Child222'
It's working fine for me.

OSS Nexus: how to use REST API to retrieve last version as a text

I'd like to retrieve the latest version name (as text) to be able to rename the artificats retrieved from Nexus which have timestamps.
What I do is create an archive of several archives containing in-house jar projects, dependencies, related scripts, ... But if the packaged jars are snapshots, the archives end up with timestamps when downloaded. Those timestamps replace the X.X.X-SNAPSHOT extension of the archive and I cannot make any automated script to perform some tasks like extracting the archive, renaming the directory, make some symbolic links, ...
I did not find anything related to this in the rest api documentation. Is there a simple way to do this with the rest api or some kind of scripting?
Thanks.
Edit:
From the below answer I managed to retrieve the latest snapshot version using LATEST instead of the version name:
Then using a script I can retrieve the base version.
#!/bin/bash
VERSION=`curl --silent "http://redmine.saic.int:8081/nexus/service/local/artifact/maven/resolve?r=snapshots&g=com.g2mobility&a=G2-Modem-Mgr&v=LATEST&c=executable&e=tar.gz" | sed -n 's|<baseVersion>\(.*\)</baseVersion>|\1|p'`
VERSION=`echo "$VERSION" | tr -d ' '`
echo "Version is $VERSION"
Thanks!
Nexus has the following REST API for describing how Maven modules are resolved:
Artifact Maven Resolve
Example
To obtain the details about the following artifact:
<groupId>org.cometd.jetty</groupId>
<artifactId>cometd-jetty-client</artifactId>
<version>1.0-SNAPSHOT</version>
Use the following REST API:
https://oss.sonatype.org/service/local/artifact/maven/resolve?r=cometd-snapshots&g=org.cometd.jetty&a=cometd-jetty-client&v=1.0-SNAPSHOT&e=jar
Returns the following report:
<artifact-resolution>
<data>
<presentLocally>true</presentLocally>
<groupId>org.cometd.jetty</groupId>
<artifactId>cometd-jetty-client</artifactId>
<version>1.0-20090313.100344-2</version>
<baseVersion>1.0-SNAPSHOT</baseVersion>
<extension>jar</extension>
<snapshot>true</snapshot>
<snapshotBuildNumber>2</snapshotBuildNumber>
<snapshotTimeStamp>1236938624000</snapshotTimeStamp>
<sha1>0cbf7163f19bf4586e27632a1f742dd0c0e0036d</sha1>
<repositoryPath>/org/cometd/jetty/cometd-jetty-client/1.0-SNAPSHOT/cometd-jetty-client-1.0-20090313.100344-2.jar</repositoryPath>
</data>
</artifact-resolution>
This was an eariler deleted posting proposing an alternative way of assembling distributions from Maven repository content:
Ivy is an alternative dependency management client, which can be run from the command-line as follows:
java -jar ivy.jar -settings ivysettings.xml -dependency org.cometd.jetty cometd-jetty-client 1.0-SNAPSHOT -retrieve "distrib/[artifact]-[revision](-[classifier]).[ext]"
The retrieve option of the ivy command details how the downloaded files should be stored locally:
-- distrib
|-- cometd-api-1.0-SNAPSHOT.jar
|-- cometd-jetty-client-1.0-SNAPSHOT.jar
|-- cometd-jetty-client-1.0-SNAPSHOT-javadoc.jar
|-- cometd-jetty-client-1.0-SNAPSHOT-sources.jar
|-- cometd-jetty-server-1.0-SNAPSHOT.jar
|-- jetty-6.1.15.jar
|-- jetty-client-6.1.15.jar
|-- jetty-sslengine-6.1.15.jar
|-- jetty-util5-6.1.15.jar
|-- jetty-util-6.1.15.jar
`-- servlet-api-2.5-20081211.jar
The correct timestamped artifact is retrieved but the "SNAPSHOT" revision number is preserved, which is what I understand you're trying to do.
The ivysettings file details the repositories to be used when downloading artifacts:
<ivysettings>
<settings defaultResolver="repos"/>
<resolvers>
<chain name="repos">
<ibiblio name="central" m2compatible="true"/>
<ibiblio name="cometd-snapshot" root="https://oss.sonatype.org/content/repositories/cometd-snapshots/" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
The documentation for the Maven Resolve Nexus REST API can be found here: https://maven.java.net/nexus-core-documentation-plugin/core/docs/rest.artifact.maven.resolve.html