Alexicon
Alexicon
CC#
Created by Alexicon on 6/20/2024 in #help
Strange seemingly new behavior of docker-compose with dot net C# solution
Here is the relavant task that is failing with the error in my post:
jobs:
- job: ${{parameters.jobName}}
displayName: 'Build Docker container'
...

steps:
- ...

- task: DockerCompose@0
displayName: docker-compose build my-solution
inputs:
azureSubscription: ...
azureContainerRegistry: ...
dockerComposeFile: 'docker-compose.yml'
dockerComposeFileArgs: |
TAG=1.0.$(Build.BuildId)
REGISTRY=$(registryEndpoint)
dockerComposeCommand: 'build my-solution'

- ...
jobs:
- job: ${{parameters.jobName}}
displayName: 'Build Docker container'
...

steps:
- ...

- task: DockerCompose@0
displayName: docker-compose build my-solution
inputs:
azureSubscription: ...
azureContainerRegistry: ...
dockerComposeFile: 'docker-compose.yml'
dockerComposeFileArgs: |
TAG=1.0.$(Build.BuildId)
REGISTRY=$(registryEndpoint)
dockerComposeCommand: 'build my-solution'

- ...
13 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
I can see the value in that format but to be honest I will probably leave it as is since I prefer this setup for what I need from it.
47 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
/close
47 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
Wow, I should have thought of that. You were correct, the test was re-building the solution causing it to generate packages again, I guess. To fix it all I had to change was the dotnet test to the following:
run: dotnet test --no-build --configuration Release --verbosity normal
run: dotnet test --no-build --configuration Release --verbosity normal
Which makes complete sense now that I look at it. Thanks for helping me with this!
47 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
Maybe I am confused about something, where did you take that screenshot exactly?
47 replies
CC#
Created by cisflex on 10/31/2023 in #help
canvas keydown event binding mvvm
note that in order to actually use the key events on the canvas you have to give that canvas the focus which means you have to set the focusable property to true and explicitly give it focus in code, for example:
<Canvas
x:Name="MyCanvas"
Focusable="True">

...

</Canvas>
<Canvas
x:Name="MyCanvas"
Focusable="True">

...

</Canvas>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

MyCanvas.Focus();
}
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

MyCanvas.Focus();
}
}
Alternativly you can just use the key down event on say the window instead and avoid this, for example:
<Window
...
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
...>

<b:Interaction.Triggers>
<b:EventTrigger EventName="KeyDown">
<b:InvokeCommandAction
Command="{Binding MyKeyDownCommand}"
PassEventArgsToCommand="True"/>
</b:EventTrigger>
</b:Interaction.Triggers>

...

</Window>
<Window
...
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
...>

<b:Interaction.Triggers>
<b:EventTrigger EventName="KeyDown">
<b:InvokeCommandAction
Command="{Binding MyKeyDownCommand}"
PassEventArgsToCommand="True"/>
</b:EventTrigger>
</b:Interaction.Triggers>

...

</Window>
I have a simple working example of all this here: https://github.com/AlexLexicon/Discord.Example.CanvasEventBinding
4 replies
CC#
Created by cisflex on 10/31/2023 in #help
canvas keydown event binding mvvm
Welcome to the world of event binding in mvvm with wpf. In order to bind an event to a command in your view model I reccomend using the nuget package: 'Microsoft.Xaml.Behaviors.Wpf' Once you have this package installed in your wpf project you can add the following xaml on any element that has events:
<b:Interaction.Triggers>
<b:EventTrigger EventName="the name of the event you want to bind to">
<b:InvokeCommandAction Command="{Binding the name of your command in your view model}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
<b:Interaction.Triggers>
<b:EventTrigger EventName="the name of the event you want to bind to">
<b:InvokeCommandAction Command="{Binding the name of your command in your view model}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
So to do what you want to do you would install that package, add a xmlns refrence, and add the following to your canvas:
<!--Add xmlns-->
<Window
...
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
...>

...

</Window>
<!--Add xmlns-->
<Window
...
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
...>

...

</Window>
<!--Add EventTrigger-->
<Canvas ...>

<b:Interaction.Triggers>
<b:EventTrigger EventName="KeyDown">
<b:InvokeCommandAction
Command="{Binding MyKeyDownCommand}"
PassEventArgsToCommand="True"/>
</b:EventTrigger>
</b:Interaction.Triggers>

...
</Canvas>
<!--Add EventTrigger-->
<Canvas ...>

<b:Interaction.Triggers>
<b:EventTrigger EventName="KeyDown">
<b:InvokeCommandAction
Command="{Binding MyKeyDownCommand}"
PassEventArgsToCommand="True"/>
</b:EventTrigger>
</b:Interaction.Triggers>

...
</Canvas>
I added the 'PassEventArgsToCommand' since I assume you are going to try and detect which keys are being pressed, this will mean in your command method within the view model you can do something like:
public void OnKeyDown(object? args)
{
if (args is KeyEventArgs e)
{
if (e.Key is Key.D)
{
...
}
else if (e.Key is Key.A)
{
...
}
}
}
public void OnKeyDown(object? args)
{
if (args is KeyEventArgs e)
{
if (e.Key is Key.D)
{
...
}
else if (e.Key is Key.A)
{
...
}
}
}
4 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
oh sorry the nuspec was a mistake on my part, they are nupkg files not nuspec. I will edit my response accordingly
47 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
@TeBeClone if I run a simple dotnet build locally like the following:
dotnet build --configuration Release --no-restore /p:VersionPrefix=7.0.12345
dotnet build --configuration Release --no-restore /p:VersionPrefix=7.0.12345
I do see the correct package being generated
Successfully created package 'C:\Users\alexr\source\repos\Lexicom\Lexicom.Maths\bin\Release\Lexicom.Maths.7.0.12345.n
upkg'.
Successfully created package 'C:\Users\alexr\source\repos\Lexicom\Lexicom.Maths\bin\Release\Lexicom.Maths.7.0.12345.n
upkg'.
and the release folder on my file system only contains the 'Lexicom.Maths.7.0.12345.nupkg' file and not a 'Lexicom.Maths.1.0.0.nupkg'. In your screenshot I can see that the package that was created was in the debug folder but my yml pipeline builds for release configuration and shouldnt generate any debug output I wouldn't think
47 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
I have to assume that I have missed something but at this point I feel like I have looked over everything and nothing seems incorrect or different than what I had before.
47 replies
CC#
Created by Alexicon on 10/31/2023 in #help
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
I cant figure out why this new project doesn’t work like the rest and is not correctly pushed as a 7.0.[run number] version. I can even see in the build logs of the workflow that the correct nupkg file is being created.
MyProject -> D:\a\MyRepo\MyRepo\MyProject\bin\Release\net7.0\MyProject.dll
Successfully created package 'D:\a\MyRepo\MyRepo\MyProject\bin\Release\MyProject.7.0.49.nupkg'.
MyProject -> D:\a\MyRepo\MyRepo\MyProject\bin\Release\net7.0\MyProject.dll
Successfully created package 'D:\a\MyRepo\MyRepo\MyProject\bin\Release\MyProject.7.0.49.nupkg'.
The project’s csproj file looks like this:
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageReadmeFile>README.md</PackageReadmeFile>

<Authors>...</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>...</Description>
<Copyright>...</Copyright>
<PackageProjectUrl>...</PackageProjectUrl>
<RepositoryUrl>...</RepositoryUrl>
<RepositoryType>...</RepositoryType>
<PackageTags>...</PackageTags>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageReadmeFile>README.md</PackageReadmeFile>

<Authors>...</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>...</Description>
<Copyright>...</Copyright>
<PackageProjectUrl>...</PackageProjectUrl>
<RepositoryUrl>...</RepositoryUrl>
<RepositoryType>...</RepositoryType>
<PackageTags>...</PackageTags>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

</Project>
I also thought maybe the 1.0.0.nupkg file was pushed in a commit by accident but it does not exist in the git repo and is correctly part of the .gitignore anyway. The only other new thing that I did was add an x-unit test project and the dot net test part of the workflow but that should not cause any issues I wouldn't think. It’s been impossible to google this specific issue since everything just takes me to how to push NuGet packages which I already know how to do. If you need the concrete details, you can view this on the actual GitHub page since this repo is public: https://github.com/AlexLexicon/Lexicom/actions/runs/6701136141/job/18208104259
47 replies
CC#
Created by Alexicon on 3/4/2023 in #help
❔ Suppress Visual Studio IDE0270 style rule without adding '.editorconfig'
@whiteviperx that might work. I am away right now but will try that when I get a chance
9 replies
CC#
Created by Alexicon on 3/4/2023 in #help
❔ Suppress Visual Studio IDE0270 style rule without adding '.editorconfig'
@whiteviperx Maybe but like I said I want to make it permanent since I am working in several solutions and I don't want to modify the repositories. All other code styles I have managed to configure but this one.
9 replies
CC#
Created by Alexicon on 1/23/2023 in #help
✅ Simple way to push a C# project as a NuGet package within a GitHub workflow yml
@TeBeConsulting Hey thanks for the refactored implementation. I changed my pipeline to reflect those changes you recommended. However the path part ''./build/packages/*.nupkg" doesnt work. Something to due with running on windows instead of Linux I think, but thats fine honestly.
21 replies
CC#
Created by Alexicon on 1/23/2023 in #help
✅ Simple way to push a C# project as a NuGet package within a GitHub workflow yml
Awesome thanks @Angius , In case anyone else wants another example here is what I ended up doing
name: Build and Publish Nuget Packages

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Install .NET 7
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.x

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Pack myproject
run: dotnet pack myproject/myproject.csproj --configuration Release --no-build /p:Version=7.0.$env:GITHUB_RUN_NUMBER

- name: Push
run: dotnet nuget push */**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
name: Build and Publish Nuget Packages

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Install .NET 7
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.x

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Pack myproject
run: dotnet pack myproject/myproject.csproj --configuration Release --no-build /p:Version=7.0.$env:GITHUB_RUN_NUMBER

- name: Push
run: dotnet nuget push */**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
21 replies
CC#
Created by Jexs on 1/8/2023 in #help
❔ Hi i need wpf help
The reason you are getting the squiggly line is because you did not paste those properties inside the Grid's angle brackets. In the example its like this:
<Grid Name="pnlMainGrid" ...>
<Grid Name="pnlMainGrid" ...>
But in your code you have:
<Grid> Name="pnlMainGrid ...
<Grid> Name="pnlMainGrid ...
14 replies
CC#
Created by Tanatozzz on 12/23/2022 in #help
✅ data from excel to wpf app
Here is the full code behind I used for this example incase it also helps (keep in mind if you plan to use a view model its basically the same thing):
public partial class MainWindow : Window
{
public MainWindow()
{
MyDataTable = new DataTable();

string csv =
"""
name,price,color
car,20000,red
house,300000,brown
lamp,25,white
""";

CreateDataTableFromCsv(csv);

InitializeComponent();
}

public DataTable MyDataTable { get; }

public void CreateDataTableFromCsv(string csv)
{
bool isFirst = true;
foreach (string row in csv.Split(Environment.NewLine))
{
DataRow dataRow = MyDataTable.NewRow();

string[] columns = row.Split(',');
for (int columnIndex = 0; columnIndex < columns.Length; columnIndex++)
{
string column = columns[columnIndex];

//we assume that the first row are the column headers
if (isFirst)
{
MyDataTable.Columns.Add(column);
}
else
{
dataRow[columnIndex] = column;

}
}

if (!isFirst)
{
MyDataTable.Rows.Add(dataRow);
}

isFirst = false;
}
}
}
public partial class MainWindow : Window
{
public MainWindow()
{
MyDataTable = new DataTable();

string csv =
"""
name,price,color
car,20000,red
house,300000,brown
lamp,25,white
""";

CreateDataTableFromCsv(csv);

InitializeComponent();
}

public DataTable MyDataTable { get; }

public void CreateDataTableFromCsv(string csv)
{
bool isFirst = true;
foreach (string row in csv.Split(Environment.NewLine))
{
DataRow dataRow = MyDataTable.NewRow();

string[] columns = row.Split(',');
for (int columnIndex = 0; columnIndex < columns.Length; columnIndex++)
{
string column = columns[columnIndex];

//we assume that the first row are the column headers
if (isFirst)
{
MyDataTable.Columns.Add(column);
}
else
{
dataRow[columnIndex] = column;

}
}

if (!isFirst)
{
MyDataTable.Rows.Add(dataRow);
}

isFirst = false;
}
}
}
20 replies
CC#
Created by Tanatozzz on 12/23/2022 in #help
✅ data from excel to wpf app
20 replies
CC#
Created by Dawnbomb on 12/21/2022 in #help
❔ WPF How to change button hover color?
So I went ahead and made a full example showing what I think it is you want. Again here is the source code: https://github.com/AlexLexicon/Discord.Example.ThemesAndStyles But also here is a video where I am demoing it. https://www.youtube.com/watch?v=mhg_UpsciHM Notice how simple the actual view code is (The xaml for the MainWindow), Yes styles are annoying but once you have defined them all of your elements of that type can use them. You will also notice I am not even telling it to use those styles but it still is. Thats because if you do not give a style a "x:Key" then it is used as the default style for all those types of elements which makes it nice to use.
130 replies
CC#
Created by Dawnbomb on 12/21/2022 in #help
❔ WPF How to change button hover color?
well the second one is using listboxitems rather than comboboxitems
130 replies