Closed IZaiarnyi closed 2 years ago
Hi @IZaiarnyi , let's try to figure what goes wrong here! First, last screenshot shots analyzers and issues that could happen, so that won't help. Could you try to go console, navigate to folder where *.sln is and execute 'dotnet build' there? It should reveal the real error.
Thank you for your quick response. After executing 'dotnet build' I got this message
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
- The following frameworks were found:
3.1.2 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
However, I got a successful build when I tried to build it one more time with the help of Rider. Currently, I cannot reproduce the error with either 'dotnet build' or Rider build.
That's weird, because I've seen your project targets netcoreapp3.1
.
I guess I can be some weird issue with Rider itself. You can try to install sdk from here https://dotnet.microsoft.com/download/dotnet-core/2.1 and try again with dotnet build
It is really weird I am not able to reproduce this error anymore. Probably, it is some setting of Rider that I missed configuring. I believe that we can close the issue and thank you for your help.
Always welcome! Feel free to reopen if happens again
I bumped upon that issue today. I want to try AspectInjector but I'm unable to build the solution.
I created a new solution in rider with a console project.
csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspectInjector" Version="2.4.1" />
</ItemGroup>
</Project>
Program.cs:
namespace AspectInjerctorDemo
{
using System;
using AspectInjector.Broker;
public class Foo
{
[MyAttribute]
public void Bar(int val)
{
Console.WriteLine(val);
}
}
[Aspect(Scope.Global)]
[Injection(typeof(MyAttribute))]
public class MyAttribute : Attribute
{
[Advice(Kind.Before)]
public void PreProcess([Argument(Source.Name)] string name)
{
Console.WriteLine($"Calling {name} method");
}
}
class Program
{
static void Main(string[] args)
{
var asd = new Foo();
asd.Bar(3);
}
}
}
When I build the project from rider I'm getting:
I also have errors in analyzers:
When I run dotnet build
in terminal I have no issues:
Rider Toolset and Build section point to the same dotnet binary:
I'm on Rider v2020.2
Hi @panosru , it seems like an issue with Rider. Could you please dig and find the whole build log produced by Rider when build happens?
There should be a message that right before 'Aspect Injector processing has failed. See other errors'.
One more question - are you sure you have error in analyzers? I'm not that familiar with Rider, and the screen you posted looks good to me
@pamidur I'm sorry, regarding analyzers it was my mistake, I have no errors in analyzers.
The part related to AspectInjector is the following:
18:21:50.585 1>Target "_ASI_InjectAspectsCore: (TargetId:73)" in file "/Users/panosru/.nuget/packages/aspectinjector/2.4.1/buildTransitive/netstandard2.0/AspectInjector.targets" from project "/Volumes/Projects/RND/VisualStudio/JustDemo/AOP/AspectInjerctorDemo/AspectInjerctorDemo.csproj" (target "InjectAspects" depends on it):
Task "Message" skipped, due to false condition; ( '$(_ASI_Debug)' == 'true' ) was evaluated as ( 'false' == 'true' ).
Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Exec" (TaskId:46)
/var/folders/11/5vttgmqd6z327wdlspbkxg940000gn/T/tmp19e3825d66ac4e0f9f7b401451aaae51.exec.cmd: line 2: dotnet: command not found (TaskId:46)
The command "dotnet --roll-forward-on-no-candidate-fx 2 "/Users/panosru/.nuget/packages/aspectinjector/2.4.1/buildTransitive/netstandard2.0/../../build/_bin/AspectInjector.dll" -rf "/Volumes/Projects/RND/VisualStudio/JustDemo/AOP/AspectInjerctorDemo/obj/Debug/netcoreapp3.1/AspectInjerctorDemo.dll._asi_refs" "/Volumes/Projects/RND/VisualStudio/JustDemo/AOP/AspectInjerctorDemo/obj/Debug/netcoreapp3.1/AspectInjerctorDemo.dll"" exited with code 127. (TaskId:46)
Done executing task "Exec". (TaskId:46)
Using "Error" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Error" (TaskId:47)
18:21:50.597 1>AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors.
Done executing task "Error" -- FAILED. (TaskId:47)
And the full build log is here.
This one looks weird
line 2: dotnet: command not found
Idk if this issue has something to do with it https://github.com/dotnet/sdk/issues/5777, but I doubt. It seems like Rider has it's own way to do stuff and for some reason it does not work.
I have just tried to install Rider on my laptop(windows) and it works just fine.
Could you please drop contents of
/var/folders/11/5vttgmqd6z327wdlspbkxg940000gn/T/tmp19e3825d66ac4e0f9f7b401451aaae51.exec.cmd
?
I have no errors in analyzers
It just shows that particular Analyzer may find errors I guess
As a temporal measure it might help to disable ReSharper Build
https://www.jetbrains.com/help/rider/Settings_Toolset_and_Build.html#build-engine
It seems like "ReSharper Build" is an attempt to optimize something. However the MSBuild (dotnet build) is quite good as well and supports incremental build, so I honestly don't see why they have this option be default., considering it might break things.
/var/folders/11/5vttgmqd6z327wdlspbkxg940000gn/T/tmp19e3825d66ac4e0f9f7b401451aaae51.exec.cmd
is a temp file that most likely is created during the build process and then is removed because I don't see it in the path:
Disabling ReSharper build doesn't help, the result log is identical with the one I posted previously.
Could you please create a new csproj file with the following content and build it in Rider
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="dotnet --version" />
</Target>
</Project>
@pamidur I did it and I got the following error:
Log:
19:33:53.241 2>Target "PreBuild: (TargetId:24)" in project "/Volumes/Projects/RND/VisualStudio/JustDemo/AOP/ConsoleApp1/ConsoleApp1.csproj" (target "PreBuildEvent" depends on it):
Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Exec" (TaskId:17)
Task Parameter:Command=dotnet --version (TaskId:17)
dotnet --version (TaskId:17)
/var/folders/11/5vttgmqd6z327wdlspbkxg940000gn/T/tmpb3bde8463f284346a0797ccaf8fb9fe1.exec.cmd: line 2: dotnet: command not found (TaskId:17)
19:33:53.250 2>/Volumes/Projects/RND/VisualStudio/JustDemo/AOP/ConsoleApp1/ConsoleApp1.csproj(8,9): error MSB3073: The command "dotnet --version" exited with code 127.
Done executing task "Exec" -- FAILED. (TaskId:17)
Full log here.
Could it be a Rider bug? At least on macOS? If so, then I'll create an issue in JetBrains YouTrack.
I wonder if that could somehow be related to https://youtrack.jetbrains.com/issue/RIDER-42713
I was to create the issue on their tracker too, but the one you've mentioned looks it is related. Have you tried their workaround - to add dotnet bin to system's PATH?
I am indeed using zsh, but I just tested with bash to make sure and dotnet bin is in bash Path as well.
Zsh (~/.zshenv):
Bash (~/.bash_profile):
In mac, there isn't /etc/profile.d
, there is /etc/profile
file, but you cannot modify it even with sudo vi
.
If you proceed on creating an issue for Rider, feel free to use all the info I posted here, including the images, also if you need any additional testing on mac, let me know and I'll do it as soon as possible.
I'm not a mac user, I found this on internets:
To permanently add a PATH entry for all users on Mac OS (global), the /etc/paths file is used.
sudo nano /etc/paths
@pamidur /etc/paths
already had the path that lead to dotnet
binary:
So I guess it isn't PATH issue, it must be something else.
I am having this same issue. I can build via terminal with dotnet build but not from within rider. Curious if anyone has figured out the root cause here.
Try building this csproj alone:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="dotnet --version" />
</Target>
</Project>
If it doesn't then the reason is that the Rider screws environment variables when it triggers the build. Basically when the build starts the Rider creates another shell process without copying envs
You may want to compare outputs of
echo $PATH
and
dotnet build
this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Message Text="$(PATH)" Importance="high" />
</Target>
</Project>
Just wanted to report back. Went to try your suggestions today and everything is working as it should.
I'm terribly sorry for not replying in time (lol, 1 year late...), I couldn't spend time on it due to various reasons, but today I tried it again from scratch and it works fine! I believe this issue can be closed :)
Thank you for circling back to us! Glad to know it is fixed now!
I'm new to C# and start my first project with Rider on MacOS.
I created the solution based on netcoreapp 3.1, installed AspectInjector Version="2.3.1" with the help of NuGet and build my source. TestProject1.zip
Actual result: Aspect Injector processing has failed. See other errors
Expected result: The solution is successfully built
Moreover, I see some problem with Aspect Analyzer
What do I do wrong?