Hi,
We have a large solution where we put our global usings in 2 seperate files:
- GlobalUsings.Solution.cs
- GlobalUsings.Tests.cs
We attach these two global usings files using a Directory.Build.props file:
(part of the Directory.Build.props file)
<ItemGroup>
<Compile Include="$(SolutionDir)\GlobalUsings.Solution.cs" Link="GlobalUsings.Solution.cs" />
</ItemGroup>
<ItemGroup Condition="$(AssemblyName.Contains('UnitTest'))
OR $(AssemblyName.Contains('Specifications'))
">
<Compile Include="$(SolutionDir)\GlobalUsings.Tests.cs" Link="GlobalUsings.Tests.cs" />
</ItemGroup>
When enabling NCrunch, we encounter a load failing project having this exception:
System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --> System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter: lenght
at System.String.Substring(Int32 startIndex, Int32 length)
at nCrunch.Compiler.BuildXml.AddTargetScript(String targetName, String dependsOnTargerts, String targetScript)
Notice that I have enabled LongPathEnabled in the registry, and I also re-allocated the workspace dir to :
c:\dev\NCrunch
Build/Test Issues
ArgumentOutOfRangeException when using shared link global usings
Started by DrDelete on 1,678 views
Remco NCrunch Developer
#16917
02 Nov 2023 23:24 UTC
Hi, thanks for sharing this issue.
Could you check whether the project files involved each have a correct closing tag in the form of: </Project> ?
This error seems to be related to the tag not being found or perhaps being syntactically different.
Could you check whether the project files involved each have a correct closing tag in the form of: </Project> ?
This error seems to be related to the tag not being found or perhaps being syntactically different.
Remco wrote:Hi, thanks for sharing this issue.
Could you check whether the project files involved each have a correct closing tag in the form of: </Project> ?
This error seems to be related to the tag not being found or perhaps being syntactically different.
Wooww... that was the issue, thanks!
Our failing project had this:
<Project Sdk="Microsoft.NET.Sdk"/>
It now loads correctly with this content:
<Project Sdk="Microsoft.NET.Sdk">
</Project>
Question: Why did my inital .csproj content not work ? (without the closing tag)
Second question/request: I didn't manage to copy the whole exception stacktrace content from the Trace Output window (I typed the exception stacktrace in first post word for word...), can this be fixed ? I could select all content, but CTRL+C or a copy context menu was not possible...
Edited 03 Nov 2023 06:04 UTC
Remco NCrunch Developer
#16919
03 Nov 2023 06:12 UTC
DrDelete wrote:
Question: Why did my inital .csproj content not work ? (without the closing tag)
NCrunch does some limited parsing of the project file when modifying it to include a few extra things to adjust MSBuild behaviour. It's a bit tacky, but we've found this to be the fastest and most effective way to get what we want from MSBuild.
The way we conduct this differs from how MSBuild loads the project file, so it's possible for us to explode on certain things that MSBuild might tolerate (and vice versa). If enough people get hit with this problem, we can make an effort to improve the experience a bit.
DrDelete wrote:
Second question/request: I didn't manage to copy the whole exception stacktrace content from the Trace Output window (I typed the exception stacktrace in first post word for word...), can this be fixed ? I could select all content, but CTRL+C or a copy context menu was not possible...
There have been reports of this issue. I've yet to find a way to reproduce it. I think there is something intermittently failing with the copy operation. Can you get it to fail consistently? Does it work for you in some situations and fail in others? I'd like to fix this one.
Remco wrote:DrDelete wrote:
Question: Why did my inital .csproj content not work ? (without the closing tag)
NCrunch does some limited parsing of the project file when modifying it to include a few extra things to adjust MSBuild behaviour. It's a bit tacky, but we've found this to be the fastest and most effective way to get what we want from MSBuild.
The way we conduct this differs from how MSBuild loads the project file, so it's possible for us to explode on certain things that MSBuild might tolerate (and vice versa). If enough people get hit with this problem, we can make an effort to improve the experience a bit.
DrDelete wrote:
Second question/request: I didn't manage to copy the whole exception stacktrace content from the Trace Output window (I typed the exception stacktrace in first post word for word...), can this be fixed ? I could select all content, but CTRL+C or a copy context menu was not possible...
There have been reports of this issue. I've yet to find a way to reproduce it. I think there is something intermittently failing with the copy operation. Can you get it to fail consistently? Does it work for you in some situations and fail in others? I'd like to fix this one.
-> we can manage this issue by using a closing tag, so not a big deal at the moment
-> you might reproduce this copy/paste issue by creaing a small project in .net7 having no closing tag ;-)
Post a reply
Log in to reply.