A colleague has downloaded my project which I've composed using IntelliJ-2019.2
On my machine, there is no .iml file (not in project root, nor in .idea folder).
He opened it using IntelliJ-2018.1 and a .iml file was created in project root.
We thought we could: Close IntelliJ-2018, uninstall, install 2019.2, delete the .iml and reopen the project with 2019.2.
However, that .iml file was created again...
Since he will be pushing to a repo, and in general because we want the whole team to work in the same way, I would like to remove this .iml, so that his project is handled by the IDE in the same way as the rest of the team.
How to "migrate" from .iml to whatever project configuration (module description) I am using (which has no .iml)?
if you use git, just add *.iml to the .gitignore file in the root of the project.
checkout https://www.gitignore.io/ to create a .gitignore for you project
in your case you need at least: https://www.gitignore.io/api/intellij
.iml file is a module file and generated by Intellij idea IDE that is used for keeping module configuration.
More info : https://www.jetbrains.com/help/idea/creating-and-managing-modules.html
For most of the people not familiar with module configuration, we don't have to worry about this file. Since it is auto generated file and used by Intellij Idea IDE, it is not needed for other team members.
To get rid of my-project.iml file I have tried 2 ways and both works :
Method 1:
add the .iml file to .gitignore file of you project.
Method 2:
Move it to any other directory on you system.
Move the file to any other directory (I moved it inside .idea directory of project as it waas added to gitignore)
Open module.xml file present in you .idea folder of project
Modify this part and update new path for the .iml file
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/my-project.iml" filepath="$PROJECT_DIR$/.idea/my-project.iml" />
</modules>
</component>
In the case of a vite project that stopped loading when i deleted the .iml file, i noticed (thanks to the second answer) that you can simply replace:
<module fileurl="..../some.iml"></module>
with the contents of some.iml:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<!-- previous contents: -->
<!--<module fileurl=""></module>-->
<!-- replacement contents: -->
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
</modules>
</component>
</project>
and the project works after using the repair ide function to reopen the project.
Related
In similar questions I could not find a sufficient answer. I followed the IntelliJ tutorial for Groovy, but it did solve the solution. Finally I solved it via a 1A4 Maven file.
For getting started more easy, maybe you could help me and others with Groovy in IntelliJ.
What did I do:
I installed the Groovy SDK
I started IntelliJ, created a new Groovy project and I could see the library was added.
After creating my first Groovy class, a compile error mentioned:
Error: Cannot compile Groovy files: no Groovy library is defined
I double checked that the library is there. And I also added the library to the module via the File > project structure > libraries. I get this result:
Added on request: I added project structure > modules > dependencies:
How your .iml file looks like?
I repeated all steps from your message and have successfully run GroovyDemo.groovy class without any errors.
My .iml file is:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="groovy-2.4.15" level="application" />
</component>
</module>
Make sure what you have groovy library inside. If you don't have it, you need to open project setting and add it manually into Libraries or Global Libraries.
I'm using IDEA 2018.1.6 UE. What is your version?
EDIT 1:
I finally reproduce your error.
I delete .idea folder from my project scope;
I open old project and it recreate the whole structure;
After that I see the same error when trying to run groovy class
I fix it by manually add groovy library to the project dependencies.
ctrl+shift+alt+s.place in Project Structure.then setting your Libraries,attending to your groovy install-file-folder lib--> groovy-***.jar。
I am in IntelliJ IDEA 2017.1.2. I recently renamed a module from mod_plus to exp-packs and now I keep getting the error:
Error Loading Project: Cannot load module mod_plus
The old module does not exist. Under File-> Project Structure->Modules->Dependencies it does not show up, it was there, but I removed it when I first saw the error. It does not show up in the .iml file:
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Pyhton-Snippets" />
<orderEntry type="module" module-name="exp_packs" />
</component>
</module>
In the event log, when I click 'Details' and it asks do I want to remove, I click YES and it is gone for that session, but on restart it comes back. Any thoughts on how to get rid of it?
IntelliJ IDEA loads modules according to .idea/modules.xml file which contains the relative paths to the .iml files.
If you rename a module in IntelliJ IDEA using refactoring, modules.xml file is updated automatically. In other cases you may need to update the path manually.
I'm unable to get my project to load if an included Nuget package includes files that exist in my project.
My Nuget package contains a appsettings.json file, and since my project also has an appsettings.json file, I get the following error in Visual Studio 2017:
(load failed) - Duplicated linked item found in the project: "C:\users\user\.nuget\packages\mypackage\contentFiles\any\netcoreapp1.1\appsettings.json"
If I remove the appsettings file from my project (not the Nuget package), the project loads fine, but the file is needed for the project to work.
I can't seem to remove the appsettings file from the nuget package, but this might be my only option.
'dotnet pack' seems to include this file even though my csproj file is not referencing it in the "CopyToPublishDirectory"
So the question is:
How to exclude certain files from being packaged (via dotnet pack)?
Or how to load a project where duplicated linked items exist?
My set up is different from yours, but I got a similar error message when trying to add an existing project to a solution. I tried a few things, so not sure what exactly helped solved it in the end, but here's what I did:
Cleaned the folder in which the project was located by deleting bin and obj folders
Noticed that in the csproj file of the failing to load project there were a couple of PropertyGroup and Item nodes that were not used or were empty or pointing to folders that were not on the disk anymore, so I removed those nodes.
After that I removed and re-added the project to the solution and it loaded successfully.
I managed to get it to work.
By default all content files are packaged.
To disable this I edited the csproj file as follows:
<PropertyGroup>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
<Content Include="appsettings.*">
<Pack>false</Pack>
</Content>
<ItemGroup>
This seems to be happening (among possibly other things) in projects which reference another project where there's a shared reference between the two.
For example:
Parent project [references package/dll X]
|
*-> Child, failing project [also explicitly references package/dll X]
In my case removing the X reference from the failed project helped solve the problem.
Had a similar issue, originally, clone to a new location fixed it. After it came bay I noticed in the csproj file
<ItemGroup>
<Folder Include="Helpers\" />
<Folder Include="Styles\" />
<Folder Include="Services\Interfaces\" />
<Folder Include="Controls\" />
<Folder Include="Styles\Fonts\" />
<Folder Include="ViewModels\Base\" />
<Folder Include="ViewModels\Product" />
<Folder Include="ViewModels\Invoice\" />
<Folder Include="ViewModels\Product\" />
<Folder Include="Views\Product\Popup\" />
</ItemGroup>
ViewModels\Product was referenced twice.
I use following config to unpack my files into one folder, and then rezip it into a single file:
<Target Name="Build_Package" DependsOnTargets="Build_Test">
<!-- Unzip artefacts to local workfolder -->
<unzip ZipFileName="$(MSBuildProjectDirectory)\MyZip.zip" TargetDirectory="$(MSBuildProjectDirectory)\temp\unzipped" />
<unzip ZipFileName="$(MSBuildProjectDirectory)\AnotherZip.zip" TargetDirectory="$(MSBuildProjectDirectory)\temp\unzipped" />
<!-- Zip files into one single package -->
<Zip Files="$(MSBuildProjectDirectory)\temp\unzipped"
WorkingDirectory="$(MSBuildProjectDirectory)\temp\work"
ZipFileName="$(MSBuildProjectDirectory)\temp\output\Output.zip" />
</Target>
This results in a zip file containing the subfolder unzipped which I want to remove. I´ve found the option RemoveRoot in older posts, but this is not working for me. I also can´t use the extension MSBuild.ExtensionPack.Compression.Zip.
Anyone an idea out there? Thank you! :)
I am trying to create a Nuget package for a library that depends on ghostscript and therefore references gsdll32.dll - an unmanaged library. I can't just included that a standard dll reference. Where do I put this in the nuget directory structure?
Add a build folder to the package and, if the package for example has the id MyPackage, add a MSBuild target file called MyPackage.targets to this folder. It is important that the .targets file has the same name as the .nuspec file. In the .nuspec file you must have a section like this:
<files>
<file src="lib\*.*" target="lib" />
<file src="build\MyPackage.targets" target="build" />
</files>
This will add an MSBuild element in the project file pointing to the .targets file.
Furthermore, to only register the managed dlls, add a section like this:
<references>
<reference file="MyManaged.dll" />
</references>
The .targets file should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CopyMyPackageFiles" AfterTargets="AfterBuild">
<ItemGroup>
<MyPackageFiles Include="$(MSBuildThisFileDirectory)..\lib\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(MyPackageFiles)" DestinationFolder="$(OutputPath)" >
</Copy>
</Target>
</Project>
Now, all files - including unmanaged files - will be copied to the project output folder (e.g. \bin\debug) after the build.
The above reference can work, but it actually modifies your post build event to push files over, which may not actually fix your issue if you have the situation we did.
The issue we were having was a dependent DLL could not be registered, but had to exist side by side with another DLL which needed to be registered by nuget so it needed to exist in the lib directory but not be registered.
The nuspec reference now allows you to specify which DLLs in the lib directory get explicitly registered in the visual studio project now, you simply need to add into your nuspec file in the metadata area an explicit references list (if this does not exist the default behavior of nuget is to attempt to register everything under lib).
Here is an example nuspec file of what I mean:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>SomePackageID</id>
<version>1.0.1</version>
<title>Some Package Title</title>
<authors>Some Authors</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Blah blah blah.</description>
<references>
<reference file="ceTe.DynamicPDF.Rasterizer.20.x86.dll" />
</references>
</metadata>
<files>
<file src="\\SomeNetworkLocation\ceTe.DynamicPDF.Rasterizer.20.x86.dll" target="lib\ceTe.DynamicPDF.Rasterizer.20.x86.dll" />
<file src="\\SomeNetworkLocation\DPDFRast.x86.dll" target="lib\DPDFRast.x86.dll" />
</files>
</package>
As you can see, ceTe.DynamicPDF.Rasterizer.20.x86.dll needs to be registered, but DPDFRast.x86.dll simply needs to exist in that directory to support the other DLL and won't be registered but through some dynamic referencing magic will ultimately be copied over into the destination bin directory anyway because visual studio sees that the first DLL is dependent upon the second.
Here is the original nuspec reference.
Response on the Nuget forum: http://nuget.codeplex.com/discussions/352689
pranavkm:
The SQLCE package has a similar issue that we handle via PS
scripts. Checkout out the scripts at
https://bitbucket.org/davidebbo/nugetpackages/src/1cba18b864f7/SqlServerCompact/Tools.
I largely got this to work using Lars Michael's method, but one thing I needed to add comes from James Eby's answer. Visual Studio was trying to register all the dll's in my lib directory, so I added a references element to the metadata in the nuspec file to tell it to only register the managed dll:
<references>
<reference file="FANNCSharp.dll" />
</references>
Also in
<MyPackageFiles Include="$(MSBuildProjectDirectory)\..\Packages\MyPackage\lib\*.*"/>
I first tried the id of my package FANNCSharp-x64, but it needed the full package name: FANNCSharp-x64.0.1.4.
One problem I had was that the packages path wasn't always in the same place relative to the project file. The following worked for me:
Within the NuGet package, place your unmanaged DLLs in the lib\native folder.
Add the following script to the tools folder:
install.ps1
#This script creates or updates a PackagesPath property in the project file
param($installPath, $toolsPath, $package, $project)
$project.Save()
#Load the csproj file into an xml object
[xml] $xml = Get-Content -path $project.FullName
#grab the namespace from the project element
$nsmgr = New-Object System.Xml.XmlNamespaceManager -ArgumentList $xml.NameTable
$nsmgr.AddNamespace('a',$xml.Project.GetAttribute("xmlns"))
#find or create the property
$property = $xml.Project.SelectSingleNode("//a:PropertyGroup//a:PackagesPath", $nsmgr)
if (!$property)
{
$property = $xml.CreateElement("PackagesPath", $xml.Project.GetAttribute("xmlns"))
$propertyGroup = $xml.CreateElement("PropertyGroup", $xml.Project.GetAttribute("xmlns"))
$propertyGroup.AppendChild($property)
$xml.Project.InsertBefore($propertyGroup, $xml.Project.ItemGroup[0])
}
#find the relative path to the packages folder
$absolutePackagesPath = (get-item $installPath).parent.FullName
push-location (split-path $project.FullName)
$relativePackagesPath = Resolve-Path -Relative $absolutePackagesPath
pop-location
#set the property value
$property.InnerText = $relativePackagesPath
#save the changes.
$xml.Save($project.FullName)
Add a targets file to the build folder. (Change "MyPackage" to the name of your package). Using a unique name for the target, like "CopyMyPackage", avoids conflicts with other packages trying to define the "AfterBuild" target. This targets file makes use of the $(PackagesPath) property defined by the above script.
MyPackage.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CopyMyPackage" AfterTargets="AfterBuild">
<ItemGroup>
<MyPackageSourceFiles Include="$(PackagesPath)\MyPackage.*\lib\native\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(MyPackageSourceFiles)" DestinationFolder="$(OutputPath)" >
</Copy>
</Target>
</Project>
Finally, add a "MyPackageReadMe.txt" to the Content folder. This will enable the package to install.
See also: http://alski.net/post/2013/05/23/Using-NuGet-25-to-deliver-unmanaged-dlls.aspx
For .NET Core this is pretty straightforward if you know what runtime platform your native code targets. You might notice a folder called "runtimes" in the .NET Core build folder under the bin tree when you build. It looks something like this:
These folders are designed to hold any platform specific stuff, including unmanaged/native DLLs.
In your NuGet package add a the following under the "Files" section:
<file src="[source path for file in package]" target="runtimes\[platform]\native\[file name]" />
When executing the application, the runtime environment will look for unmanaged dlls in the corresponding platform directory.
If you want to target multiple platforms, just add another file entry for each platform.