Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avalonia-amd-gen doesn't read properties in csproj #68

Open
philippelatulippe opened this issue Oct 17, 2024 · 5 comments
Open

avalonia-amd-gen doesn't read properties in csproj #68

philippelatulippe opened this issue Oct 17, 2024 · 5 comments

Comments

@philippelatulippe
Copy link

When I run avalonia-amd-gen on a project created by Rider, I get the following error:

Packages found in the .csproj file:
An error occurred: '$(AvaloniaVersion)' is not a valid version string. (Parameter 'value')
   at NuGet.Versioning.NuGetVersion.Parse(String value)
   at AvaloniaExtensionGenerator.CsProjectTypesExtractor.GetAllDependencyPackages(String packageName, String packageVersion, String targetFramework) in C:\Projects\Avalonia\Avalonia.Markup.Declarative\src\AvaloniaExtensionGenerator\CsProjectTypesExtractor.cs:line 80
   at AvaloniaExtensionGenerator.CsProjectTypesExtractor.LoadTypesFromProject(String projectPath, String baseTypeNameToFilter, String[] ignoreAssemblies) in C:\Projects\Avalonia\Avalonia.Markup.Declarative\src\AvaloniaExtensionGenerator\CsProjectTypesExtractor.cs:line 147
   at AvaloniaExtensionGenerator.Program.Main(String[] args) in C:\Projects\Avalonia\Avalonia.Markup.Declarative\src\AvaloniaExtensionGenerator\Program.cs:line 73

It looks like the csproj file reader doesn't understand variables, since the variable AvaloniaVersion is definited in PropertyGroup.

@gritsenko
Copy link
Collaborator

@philippelatulippe can you share archive with the project folder here?

@philippelatulippe
Copy link
Author

I can't share the whole project but I can certainly share the csproj:

csproj
<PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <AvaloniaVersion>11.2.0-rc1</AvaloniaVersion>
</PropertyGroup>

<ItemGroup>
    <PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Markup.Declarative" Version="11.2.0-beta4" />
    <PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0.1" />
    <PackageReference Include="FluentAvaloniaUI" Version="2.1.0" />
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
</ItemGroup>

<ItemGroup>
  <Compile Update="MainWindow.axaml.cs">
    <DependentUpon>MainWindow.axaml</DependentUpon>
    <SubType>Code</SubType>
  </Compile>
</ItemGroup>

@IvanJosipovic
Copy link
Contributor

IvanJosipovic commented Oct 17, 2024

@gritsenko, I'm starting to wonder if integrating the generation CLI into MSBuild would make it simpler. A Custom MSbuild step could get a list of all loaded libraries and that could be used to trigger the generation.

I use a MSBuild step here that runs after the ResolveReferences step.
https://github.com/IvanJosipovic/KubernetesCRDModelGen/blob/86e5de4755a0263a5017a85896c30a1c5468c966/src/KubernetesCRDModelGen/KubernetesCRDModelGen.csproj#L31

@gritsenko
Copy link
Collaborator

@IvanJosipovic I thought about it as well, but we need to generate extensions before building step already, and even when project itself has errors and can't to be built. Do you think it is possible to use msbuild in this case? Or I misunderstanding how it works?

@IvanJosipovic
Copy link
Contributor

@IvanJosipovic I thought about it as well, but we need to generate extensions before building step already, and even when project itself has errors and can't to be built. Do you think it is possible to use msbuild in this case? Or I misunderstanding how it works?

@gritsenko, I created an example PR, #70
Have a look, if its interesting, we can continue the work there. I believe we can also publish custom "MSBuild Target" as a part of the NuGet package to make it even simpler to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants