Compare commits
6 Commits
main
...
chached_st
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a13431603 | |||
| 49e16a8077 | |||
| 2075b35f7b | |||
| 4c1f36e5f8 | |||
| b62e34eea2 | |||
| 433e6a2727 |
@@ -9,16 +9,13 @@
|
|||||||
},
|
},
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
"settings": {
|
|
||||||
"terminal.integrated.defaultProfile.linux": "dev-shell"
|
|
||||||
},
|
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"formulahendry.dotnet-test-explorer",
|
"formulahendry.dotnet-test-explorer",
|
||||||
"jnoortheen.nix-ide",
|
"jnoortheen.nix-ide",
|
||||||
"eamodio.gitlens"
|
"eamodio.gitlens"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
// "features": {},
|
// "features": {},
|
||||||
@@ -32,7 +29,7 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Use 'postCreateCommand' to run commands after the container is created.
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
// "postCreateCommand": "nix-env -i nixpkgs-fmt"
|
"postCreateCommand": "nix-env -i nixpkgs-fmt"
|
||||||
|
|
||||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
// "remoteUser": "root"
|
// "remoteUser": "root"
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -475,7 +475,4 @@ $RECYCLE.BIN/
|
|||||||
|
|
||||||
# Windows shortcuts
|
# Windows shortcuts
|
||||||
*.lnk
|
*.lnk
|
||||||
|
|
||||||
# project specific
|
|
||||||
result
|
result
|
||||||
MyTestConsoleApp
|
|
||||||
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@@ -1,10 +1,3 @@
|
|||||||
{
|
{
|
||||||
"dotnet-test-explorer.testProjectPath": "**/*Tests.csproj",
|
"dotnet-test-explorer.testProjectPath": "**/*Tests.csproj"
|
||||||
"terminal.integrated.profiles.linux": {
|
|
||||||
"dev-shell": {
|
|
||||||
"path": "bash",
|
|
||||||
"args": [ "-c", "nix --experimental-features \"nix-command flakes\" develop"],
|
|
||||||
"overrideName": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
3
alias.sh
3
alias.sh
@@ -4,5 +4,4 @@ alias nixe='nix --experimental-features "nix-command flakes"'
|
|||||||
alias nulock='nixe run .#devTasks.updateNugetLock'
|
alias nulock='nixe run .#devTasks.updateNugetLock'
|
||||||
alias fllock='nixe run .#devTasks.updateFlakeLock'
|
alias fllock='nixe run .#devTasks.updateFlakeLock'
|
||||||
alias ulock='nulock && fllock'
|
alias ulock='nulock && fllock'
|
||||||
alias .net='nixe run .#devTasks.runDotNet -- $@'
|
alias restore-on-current-source='nixe build && dotnet nuget locals all -c && dotnet restore -s result/share -s https://api.nuget.org/v3/index.json $1'
|
||||||
alias rat='nixe run .#devTasks.runAllTests'
|
|
||||||
216
flake.nix
216
flake.nix
@@ -11,190 +11,78 @@
|
|||||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
scripts = forAllSystems (system: {
|
scripts = forAllSystems (system: {
|
||||||
updateFlakeLockFile = nixpkgsFor.${system}.writeScript "update_flake_lock.sh" ''
|
updateFlakeLockFile = nixpkgsFor.${system}.writeScript "update_flake_lock.sh" ''
|
||||||
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
||||||
nix --experimental-features 'nix-command flakes' build
|
nix --experimental-features 'nix-command flakes' build
|
||||||
'';
|
'';
|
||||||
|
|
||||||
updateNugetLockFile = nixpkgsFor.${system}.writeScript "update_nuget_lock.sh" ''
|
updateNugetLockFile = nixpkgsFor.${system}.writeScript "update_nuget_lock.sh" ''
|
||||||
temp_package_folder=$(mktemp -d)
|
temp_package_folder=$(mktemp -d)
|
||||||
dotnet restore ResourceString.Net --packages "$temp_package_folder"
|
dotnet restore ResourceString.Net --packages "$temp_package_folder"
|
||||||
${nixpkgsFor.${system}.nuget-to-nix}/bin/nuget-to-nix "$temp_package_folder" > ResourceString.Net/deps.nix
|
${nixpkgsFor.${system}.nuget-to-nix}/bin/nuget-to-nix "$temp_package_folder" > ResourceString.Net/deps.nix
|
||||||
rm -rf "$temp_package_folder"
|
rm -rf "$temp_package_folder"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
||||||
git tag --force v${version}
|
git tag --force v${version}
|
||||||
git push origin v${version}
|
git push origin v${version}
|
||||||
'';
|
'';
|
||||||
updateLogicResourceFile = nixpkgsFor.${system}.writeScript "update_logic_resource_file.sh" ''
|
updateLogicResourceFile = nixpkgsFor.${system}.writeScript "update_logic_resource_file.sh" ''
|
||||||
dotnet run --project ResourceString.Net.App.Console ResourceString.Net.Logic/Properties/Resources.resx ResourceString.Net.Logic.Properties > ResourceString.Net.Logic/Properties/Resources.cs.tmp
|
dotnet run --project ResourceString.Net.App.Console ResourceString.Net.Logic/Properties/Resources.resx ResourceString.Net.Logic.Properties > ResourceString.Net.Logic/Properties/Resources.cs.tmp
|
||||||
mv ResourceString.Net.Logic/Properties/Resources.cs.tmp ResourceString.Net.Logic/Properties/Resources.cs
|
mv ResourceString.Net.Logic/Properties/Resources.cs.tmp ResourceString.Net.Logic/Properties/Resources.cs
|
||||||
'';
|
'';
|
||||||
|
runAllTests = nixpkgsFor.${system}.writeScript "run_all_tests.sh" ''
|
||||||
|
dotnet test *.Tests
|
||||||
|
'';
|
||||||
buildAllAssemblies = nixpkgsFor.${system}.writeScript "build_all_assemblies.sh" ''
|
buildAllAssemblies = nixpkgsFor.${system}.writeScript "build_all_assemblies.sh" ''
|
||||||
# Find all .csproj files below the current folder
|
# Find all .csproj files below the current folder
|
||||||
csproj_files=$(find . -name '*.csproj')
|
csproj_files=$(find . -name '*.csproj')
|
||||||
|
|
||||||
# Create a temporary file to store the number of dependencies for each project
|
# Create a temporary file to store the number of dependencies for each project
|
||||||
temp_file=$(mktemp)
|
temp_file=$(mktemp)
|
||||||
|
|
||||||
# Loop through each .csproj file and count its number of ResourceString dependencies
|
# Loop through each .csproj file and count its number of ResourceString dependencies
|
||||||
for file in $csproj_files
|
for file in $csproj_files
|
||||||
do
|
do
|
||||||
count=$(cat "$file" | grep -c "<ProjectReference.*ResourceString")
|
count=$(cat "$file" | grep -c "<ProjectReference.*ResourceString")
|
||||||
depth=$(echo "$file" | tr -cd '/' | wc -c)
|
depth=$(echo "$file" | tr -cd '/' | wc -c)
|
||||||
dot_count=$(echo "$file" | tr -cd '.' | wc -c)
|
dot_count=$(echo "$file" | tr -cd '.' | wc -c)
|
||||||
echo "$depth $count $dot_count $file" >> "$temp_file"
|
echo "$depth $count $dot_count $file" >> "$temp_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Sort the projects by their count of dependencies and path depth, in ascending order
|
# Sort the projects by their count of dependencies and path depth, in ascending order
|
||||||
sorted_projects=$(sort -nk1 -nk2 -nk3 -t' ' "$temp_file" | awk '{print $4}')
|
sorted_projects=$(sort -nk1 -nk2 -nk3 -t' ' "$temp_file" | awk '{print $4}')
|
||||||
|
|
||||||
# Loop through the sorted projects and build them
|
# Loop through the sorted projects and build them
|
||||||
while read -r file
|
while read -r file
|
||||||
do
|
do
|
||||||
echo "Building project: $file"
|
echo "Building project: $file"
|
||||||
dotnet build "$file"
|
dotnet build "$file"
|
||||||
done << EOF
|
done << EOF
|
||||||
$sorted_projects
|
$sorted_projects
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Remove the temporary file
|
# Remove the temporary file
|
||||||
rm "$temp_file"
|
rm "$temp_file"
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
cleanAllAssemblies = nixpkgsFor.${system}.writeScript "clean_all_assemblies.sh" ''
|
cleanAllAssemblies = nixpkgsFor.${system}.writeScript "clean_all_assemblies.sh" ''
|
||||||
csproj_files=$(find . -name '*.csproj')
|
csproj_files=$(find . -name '*.csproj')
|
||||||
for file in $csproj_files
|
for file in $csproj_files
|
||||||
do
|
do
|
||||||
dotnet clean "$file"
|
dotnet clean "$file"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
runDefaultApp = nixpkgsFor.${system}.writeScript "run_default_app.sh" ''
|
runDefaultApp = nixpkgsFor.${system}.writeScript "run_default_app.sh" ''
|
||||||
dotnet run --project ResourceString.Net.App.Console $@
|
dotnet run --project ResourceString.Net.App.Console $@
|
||||||
'';
|
'';
|
||||||
runDotNet = nixpkgsFor.${system}.writeScript "dotnet.sh" ''
|
createNugetPackage = nixpkgsFor.${system}.writeScript "run_default_app.sh" ''
|
||||||
if [ ! -d "result/share" ]; then
|
dotnet run --project ResourceString.Net.App.Console $@
|
||||||
nix --experimental-features 'nix-command flakes' build
|
|
||||||
fi
|
|
||||||
|
|
||||||
injectable_commands="restore$2 addpackage"
|
|
||||||
|
|
||||||
for value in $injectable_commands; do
|
|
||||||
if [ "$value" = "$1$2" ] || [ "$value" = "$1$3" ]; then
|
|
||||||
dotnet nuget locals all -c
|
|
||||||
dotnet $@ -s "result/share;https://api.nuget.org/v3/index.json"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
dotnet $@
|
|
||||||
'';
|
|
||||||
|
|
||||||
runAllTests = nixpkgsFor.${system}.writeScript "run_all_tests.sh" ''
|
|
||||||
dotnet test *.Tests
|
|
||||||
|
|
||||||
echo "# test package intregation"
|
|
||||||
|
|
||||||
echo "## test example app"
|
|
||||||
|
|
||||||
${scripts.${system}.runDotNet} restore example/Example.App/
|
|
||||||
${scripts.${system}.runDotNet} build example/Example.App/
|
|
||||||
output=$(${scripts.${system}.runDotNet} run --project example/Example.App/ --no-build | tr '\n' ' ')
|
|
||||||
|
|
||||||
expected_output="Hello Value1 2Value21{2} "
|
|
||||||
if [ "$output" = "$expected_output" ]; then
|
|
||||||
echo "Output matches the expected value."
|
|
||||||
else
|
|
||||||
echo "expected output is:"
|
|
||||||
echo $expected_output
|
|
||||||
|
|
||||||
echo "but was:"
|
|
||||||
echo $output
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "## test MyTestConsoleApp"
|
|
||||||
|
|
||||||
rm -rf MyTestConsoleApp
|
|
||||||
dotnet new console --name MyTestConsoleApp
|
|
||||||
|
|
||||||
echo "<Project Sdk=\"Microsoft.NET.Sdk\">
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<AdditionalFileItemNames>$(AdditionalFileItemNames);EmbeddedResource</AdditionalFileItemNames>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
" > MyTestConsoleApp/MyTestConsoleApp.csproj
|
|
||||||
|
|
||||||
${scripts.${system}.runDotNet} add MyTestConsoleApp package "System.Resources.Extensions"
|
|
||||||
${scripts.${system}.runDotNet} add MyTestConsoleApp package "ResourceString.Net"
|
|
||||||
|
|
||||||
echo "<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<root>
|
|
||||||
<data name='Greetings'>
|
|
||||||
<value>Hello {0}</value>
|
|
||||||
<comment>0 = name</comment>
|
|
||||||
</data>
|
|
||||||
<data name='World'>
|
|
||||||
<value>World</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
||||||
" > MyTestConsoleApp/Resources.resx
|
|
||||||
|
|
||||||
echo "var message = MyTestConsoleApp.Resources.Greetings.From(
|
|
||||||
MyTestConsoleApp.Resources.World
|
|
||||||
);
|
|
||||||
|
|
||||||
Console.WriteLine(message.Value);
|
|
||||||
" > MyTestConsoleApp/Program.cs
|
|
||||||
|
|
||||||
echo "<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<root>
|
|
||||||
<data name='Greetings'>
|
|
||||||
<value>Hallo {0}</value>
|
|
||||||
<comment>0 = name</comment>
|
|
||||||
</data>
|
|
||||||
<data name='World'>
|
|
||||||
<value>Welt</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
||||||
" > MyTestConsoleApp/Resources.de.resx
|
|
||||||
|
|
||||||
echo "
|
|
||||||
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(\"de-DE\");
|
|
||||||
|
|
||||||
Console.WriteLine(message.Value);
|
|
||||||
" >> MyTestConsoleApp/Program.cs
|
|
||||||
|
|
||||||
${scripts.${system}.runDotNet} restore MyTestConsoleApp
|
|
||||||
${scripts.${system}.runDotNet} build MyTestConsoleApp
|
|
||||||
output=$(${scripts.${system}.runDotNet} run --project MyTestConsoleApp --no-build | tr '\n' ' ')
|
|
||||||
|
|
||||||
expected_output="Hello World Hallo Welt "
|
|
||||||
if [ "$output" = "$expected_output" ]; then
|
|
||||||
echo "Output matches the expected value."
|
|
||||||
else
|
|
||||||
echo "expected output is:"
|
|
||||||
echo $expected_output
|
|
||||||
|
|
||||||
echo "but was:"
|
|
||||||
echo $output
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
in rec {
|
in
|
||||||
|
rec {
|
||||||
packages = forAllSystems (system: {
|
packages = forAllSystems (system: {
|
||||||
default = nixpkgsFor.${system}.buildDotnetModule {
|
default = nixpkgsFor.${system}.buildDotnetModule {
|
||||||
pname = name;
|
pname = name;
|
||||||
@@ -252,10 +140,6 @@
|
|||||||
type = "app";
|
type = "app";
|
||||||
program = "${scripts.${system}.cleanAllAssemblies}";
|
program = "${scripts.${system}.cleanAllAssemblies}";
|
||||||
};
|
};
|
||||||
runDotNet = {
|
|
||||||
type = "app";
|
|
||||||
program = "${scripts.${system}.runDotNet}";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -265,7 +149,7 @@
|
|||||||
packages =
|
packages =
|
||||||
[ nixpkgsFor.${system}.dotnet-sdk nixpkgsFor.${system}.nixfmt ];
|
[ nixpkgsFor.${system}.dotnet-sdk nixpkgsFor.${system}.nixfmt ];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
. ./alias.sh
|
alias nixe="nix --experimental-features 'nix-command flakes'"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user