dotnet / dotnet/machinelearning-modelbuilder

ModelBuilder-generated C# isn't recognized by the compiler

Open
#2,405 5 comments 0 reactions 1 assignee Claimed by @zewditu View on GitHub
Priority:1 Reported by: Customer Stale
Dominant language
Dockerfile
Stars
285
Forks
66
PR merge metrics
No merged PRs in 30d

Description

**System Information (please complete the following information):**
- Model Builder Version (available in Manage Extensions dialog): 16.14.0.2255902
- Visual Studio Version: Visual Studio Enterprise 2022 (64-bit), Version 17.4.2

**Describe the bug**
- On which step of the process did you run into an issue: After completing Model Builder wizard and C# code is generated.
- Clear description of the problem: At least in .NET Framework 4.7.2 console apps, with a completed model training process, the generated .cs files aren't recognized by the compiler; thus, the classes (eg, `IrisModel`, `ModelInput`, `ModelOutput`) aren't accessible. The issue seems to be caused by the .csproj's `` tags:

```xml


IrisModel.mbconfig


IrisModel.mbconfig


IrisModel.mbconfig
PreserveNewest

```

If these are changed to be ``, the .cs files are treated as compiled code that is accessible to the rest of the project.

**To Reproduce**
Steps to reproduce the behavior:
1. Create new C# console app using the .NET Framework
2. Create new Model Builder config
3. Using the [Iris dataset](https://en.wikipedia.org/wiki/Iris_flower_data_set) such as the one included in the attached file, train a model; in my example, it's created with `IrisData.mbconfig`.
4. Try to access `IrisData` from `Main`: `ModelInput sampleInput = null;` will exhibit the lack of recognition of the `ModelInput` type.

**Expected behavior**
.cs files should be handled as user-created classes.

**Screenshots**
Unnecessary, but I can provide them if you'd like.

**Additional context**
According to @JakeRadMSFT, and from my own test, a .NET 6 project uses 'new-style' .csproj where all .cs files are implicitly included. Thus, this issue shouldn't present in that scenario.

[IrisData Framework472.zip](https://github.com/dotnet/machinelearning-modelbuilder/files/10159510/IrisData.Framework472.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.