C
C#•4w ago
Bruno.uy

dotnet test app.cs

.NET 10 can run a C# file directly using dotnet run app.cs. But my .cs doesn't have a Main(). It's actually a small xunit test class for https://adventofcode.com/2024/day/N Can I get away with not creating a .csproj for test files?
6 Replies
Aaron
Aaron•4w ago
probably not it would need support for the test packages and sdk, i think
333fred
333fred•4w ago
@Jan Jones, did you add dotnet test support by chance?
jjones
jjones•4w ago
Not yet, but many modern test frameworks support 'dotnet run' too, so that works fine, I've tried Here are some examples: https://github.com/DamianEdwards/runfile/pull/4/files (they just use outdated syntax for #:property, need to replace space with = as the separator) Feel free to file an issue at the dotnet/sdk repo for 'dotnet test app.cs', to show there's community demand for it 🙂
Unknown User
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
Bruno.uy
Bruno.uyOP•4w ago
Will do. Thanks a lot! IIUC, the new Microsoft.Testing.Platform builds .EXEs so it is compatible with dotnet run app.cs. The old VSTest would require dotnet test app.cs support. I'm using .NET 10 for advent of code to escape my job still stuck in .net fw, so I'm not a data point to measure community demand.
MODiX
MODiX•4w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?