Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Remove default Store user profile 2.0 #2543

Merged
merged 4 commits into from
May 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions Documentation/design-docs/DotNetCore-SharedPackageStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ To enable sharing of assemblies among all machine-wide .NET Core applications, a

### Packages Store

The package store can be either a global system-wide folder or a user local folder:
The package store can be either a global system-wide folder or a dotnet.exe relative folder:

+ **Global**:
- The `dotnet` root location -- on Windows, the folder is located in `C:\Program Files (x86)\`. See layout below.
Expand All @@ -29,17 +29,6 @@ The package store can be either a global system-wide folder or a user local fold

The layout within `netcoreapp*` folders is a NuGet cache layout.

+ **User**: The user local location can be used to override the global location when probing assemblies and uses a very similar layout, except that the `packages/install` folder is NOT supported in the user profile. It is only supported in the global location.

```
- %USERPROFILE% or $HOME/
- .dotnet
- store
- {arch=x86|x64}
= do =
```

**OPEN**: Should we have a `dotnet` relative location as well, if operating out of a zip installation of .NET Core binaries?

### Composing a runtime (non-ref) package store

Expand Down Expand Up @@ -116,15 +105,18 @@ Note that this is different from current behavior of `dotnet run` for an applica
The host will probe in the following order of precedence for `dotnet run` and application activations post `dotnet publish`:

+ `$CORE_SERVICING` on Unix or `%ProgramFiles(x86)%\coreservicing` on Windows.
+ Application Bin and Shared FX directory
+ `DOTNET_SHARED_STORE` in the chained order
+ The user local shared package store in `%USERPROFILE%\.dotnet\store` or `$HOME/.dotnet/store`
+ The global shared package store
+ The Shared Framework directory
+ ~~`DOTNET_HOSTING_OPTIMIZATION_CACHE` deprecated in favor of `DOTNET_SHARED_STORE`~~
+ `--additionalprobingpaths` specified in the command line
+ `runtimeOptions.additionalProbingPaths` (includes NuGet cache probe specified by the CLI for `dotnet run`)
+ Application `bin` directory

+ Store locations
- The dotnet.exe relative shared package store
- The global shared package store
- ~~`DOTNET_HOSTING_OPTIMIZATION_CACHE` deprecated in favor of `DOTNET_SHARED_STORE`~~
+ Additional Probing Paths
- `--additionalprobingpaths` specified in the command line
- `runtimeOptions.additionalProbingPaths` (includes NuGet cache probe specified by the CLI for `dotnet run`)

**NOTE:** `--additionalprobingpaths` can be passed template paths like below and the host will interpret `|arch|/|tfm|` appropriately to look for assets:
`%USERPROFILE%\user\cache\|arch|\|tfm|` or `$HOME/user/cache/|arch|/|tfm|`
## dotnet publish

Publish will be enhanced to support a filter profile file specified as xml. This file explicitly lists all asset packages that need to be trimmed out of the publish output. The following are examples of how various application types can be published.
Expand Down
9 changes: 0 additions & 9 deletions src/corehost/cli/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ void setup_shared_store_paths(const hostpolicy_init_t& init, const pal::string_t
// Environment variable DOTNET_SHARED_STORE
(void) get_env_shared_store_dirs(&args->env_shared_store, get_arch(), init.tfm);

// User profile based store
pal::string_t local_shared_store;
if (get_local_shared_store_dir(&local_shared_store))
{
append_path(&local_shared_store, get_arch());
append_path(&local_shared_store, init.tfm.c_str());
args->local_shared_store = local_shared_store;
}

// "dotnet.exe" relative shared store folder
if (init.host_mode == host_mode_t::muxer)
{
Expand Down
2 changes: 0 additions & 2 deletions src/corehost/cli/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ struct arguments_t
pal::string_t core_servicing;
std::vector<pal::string_t> probe_paths;
pal::string_t managed_application;
pal::string_t local_shared_store;
std::vector<pal::string_t> global_shared_stores;
pal::string_t dotnet_shared_store;
std::vector<pal::string_t> env_shared_store;
Expand All @@ -107,7 +106,6 @@ struct arguments_t
{
trace::verbose(_X("-- arguments_t: env shared store: '%s'"), shared.c_str());
}
trace::verbose(_X("-- arguments_t: local shared store: '%s'"), local_shared_store.c_str());
trace::verbose(_X("-- arguments_t: dotnet shared store: '%s'"), dotnet_shared_store.c_str());
for (const auto& global_shared : global_shared_stores)
{
Expand Down
17 changes: 0 additions & 17 deletions src/corehost/cli/deps_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ void deps_resolver_t::setup_shared_store_probes(
}
}

if (pal::directory_exists(args.local_shared_store))
{
m_probes.push_back(probe_config_t::lookup(args.local_shared_store));
}

if (pal::directory_exists(args.dotnet_shared_store))
{
m_probes.push_back(probe_config_t::lookup(args.dotnet_shared_store));
Expand Down Expand Up @@ -239,18 +234,6 @@ void deps_resolver_t::setup_probe_config(
void deps_resolver_t::setup_additional_probes(const std::vector<pal::string_t>& probe_paths)
{
m_additional_probes.assign(probe_paths.begin(), probe_paths.end());

for (auto iter = m_additional_probes.begin(); iter != m_additional_probes.end(); )
{
if (pal::directory_exists(*iter))
{
++iter;
}
else
{
iter = m_additional_probes.erase(iter);
}
}
}

/**
Expand Down
42 changes: 36 additions & 6 deletions src/corehost/cli/fxr/fx_muxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,42 @@ int muxer_usage(bool is_sdk_present)
}

// Convert "path" to realpath (merging working dir if needed) and append to "realpaths" out param.
void append_realpath(const pal::string_t& path, std::vector<pal::string_t>* realpaths)
void append_probe_realpath(const pal::string_t& path, std::vector<pal::string_t>* realpaths, const pal::string_t& tfm)
{
pal::string_t real = path;
if (pal::realpath(&real))
pal::string_t probe_path = path;

if (pal::realpath(&probe_path) && pal::directory_exists(probe_path))
{
realpaths->push_back(probe_path);
}
else
{
realpaths->push_back(real);
//Check if we can extrapolate |arch|<DIR_SEPARATOR>|tfm| for probing stores
pal::string_t placeholder = _X("|arch|");
placeholder.push_back(DIR_SEPARATOR);
placeholder.append(_X("|tfm|"));
auto pos_placeholder = probe_path.find_last_of(placeholder);

if (pos_placeholder != pal::string_t::npos)
{
pal::string_t segment = get_arch();
segment.push_back(DIR_SEPARATOR);
segment.append(tfm);
probe_path.replace(pos_placeholder - placeholder.length() + 1, placeholder.length(), segment);

if (pal::directory_exists(probe_path))
{
realpaths->push_back(probe_path);
}
else
{
trace::verbose(_X("Ignoring host interpreted additional probing path %s as it does not exist."),probe_path.c_str());
}
}
else
{
trace::verbose(_X("Ignoring additional probing path %s as it does not exist."),probe_path.c_str());
}
}
}

Expand Down Expand Up @@ -991,11 +1021,11 @@ int fx_muxer_t::read_config_and_execute(
std::vector<pal::string_t> probe_realpaths;
for (const auto& path : spec_probe_paths)
{
append_realpath(path, &probe_realpaths);
append_probe_realpath(path, &probe_realpaths, config.get_tfm());
}
for (const auto& path : config.get_probe_paths())
{
append_realpath(path, &probe_realpaths);
append_probe_realpath(path, &probe_realpaths, config.get_tfm());
}

// 'Roll forward on no candidate fx' is disabled by default. It can be enabled through:
Expand Down
11 changes: 0 additions & 11 deletions src/corehost/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,3 @@ bool get_global_shared_store_dirs(std::vector<pal::string_t>* dirs, const pal::
}
return true;
}

bool get_local_shared_store_dir(pal::string_t* dir)
{
if (!pal::get_local_dotnet_dir(dir))
{
return false;
}

append_path(dir, RUNTIME_STORE_DIRECTORY_NAME);
return true;
}
1 change: 0 additions & 1 deletion src/corehost/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ bool parse_known_args(
int* num_args);
bool skip_utf8_bom(pal::ifstream_t* stream);
bool get_env_shared_store_dirs(std::vector<pal::string_t>* dirs, const pal::string_t& arch, const pal::string_t& tfm);
bool get_local_shared_store_dir(pal::string_t* recv);
bool get_global_shared_store_dirs(std::vector<pal::string_t>* dirs, const pal::string_t& arch, const pal::string_t& tfm);
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,40 @@ public void Muxer_Exec_activation_of_Build_Output_Portable_DLL_with_DepsJson_Loc
.HaveStdOutContaining("Hello World");
}

[Fact]
public void Muxer_Activation_With_Templated_AdditionalProbingPath_Succeeds()
{
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
.Copy();

var store_path = CreateAStore(fixture);
var dotnet = fixture.BuiltDotnet;
var appDll = fixture.TestProject.AppDll;

var destRuntimeDevConfig = fixture.TestProject.RuntimeDevConfigJson;
if (File.Exists(destRuntimeDevConfig))
{
File.Delete(destRuntimeDevConfig);
}

var additionalProbingPath = store_path + "/|arch|/|tfm|";

dotnet.Exec(
"exec",
"--additionalprobingpath", additionalProbingPath,
appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdErr()
.CaptureStdOut()
.Execute()
.Should()
.Pass()
.And
.HaveStdOutContaining("Hello World")
.And
.HaveStdErrContaining($"Adding tpa entry: {Path.Combine(store_path,fixture.RepoDirProvider.BuildArchitecture, fixture.Framework)}");
}

[Fact]
public void Muxer_Exec_activation_of_Build_Output_Portable_DLL_with_DepsJson_Remote_and_RuntimeConfig_Local_Succeeds()
{
Expand Down Expand Up @@ -255,5 +289,18 @@ private void MoveRuntimeConfigToSubdirectory(TestProjectFixture testProjectFixtu

testProjectFixture.TestProject.RuntimeConfigJson = destRuntimeConfig;
}

private string CreateAStore(TestProjectFixture testProjectFixture)
{
var storeoutputDirectory = Path.Combine(testProjectFixture.TestProject.ProjectDirectory, "store");
if (!Directory.Exists(storeoutputDirectory))
{
Directory.CreateDirectory(storeoutputDirectory);
}

testProjectFixture.StoreProject(outputDirectory :storeoutputDirectory);

return storeoutputDirectory;
}
}
}
2 changes: 2 additions & 0 deletions src/test/TestUtils/DotNetCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public Command Exec(string command, params string[] args)
public Command Test(params string[] args) => Exec("test", args);
public Command Publish(params string[] args) => Exec("publish", args);

public Command Store(params string[] args) => Exec("store", args);

private void ComputeSharedFxPaths()
{
var sharedFxBaseDirectory = Path.Combine(BinPath, "shared", "Microsoft.NETCore.App");
Expand Down
3 changes: 3 additions & 0 deletions src/test/TestUtils/TestProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class TestProject
private string _projectFile;
private string _projectAssetsJson;
private string _runtimeConfigJson;
private string _runtimeDevConfigJson;
private string _depsJson;
private string _appDll;
private string _appExe;
Expand All @@ -32,6 +33,7 @@ public class TestProject
public string ProjectFile { get { return _projectFile; } set { _projectFile = value; } }
public string ProjectAssetsJson { get { return _projectAssetsJson; } set { _projectAssetsJson = value; } }
public string RuntimeConfigJson { get { return _runtimeConfigJson; } set { _runtimeConfigJson = value; } }
public string RuntimeDevConfigJson { get { return _runtimeDevConfigJson; } set { _runtimeDevConfigJson = value; } }
public string DepsJson { get { return _depsJson; } set { _depsJson = value; } }
public string AppDll { get { return _appDll; } set { _appDll = value; } }
public string AppExe { get { return _appExe; } set { _appExe = value; } }
Expand Down Expand Up @@ -71,6 +73,7 @@ public void LoadOutputFiles()
_appExe = Path.Combine(_outputDirectory, $"{_projectName}{_exeExtension}");
_depsJson = Path.Combine(_outputDirectory, $"{_projectName}.deps.json");
_runtimeConfigJson = Path.Combine(_outputDirectory, $"{_projectName}.runtimeconfig.json");
_runtimeDevConfigJson = Path.Combine(_outputDirectory, $"{_projectName}.runtimeconfig.dev.json");
_hostPolicyDll = Path.Combine(_outputDirectory, $"{_sharedLibraryPrefix}hostpolicy{_sharedLibraryExtension}");
_hostFxrDll = Path.Combine(_outputDirectory, $"{_sharedLibraryPrefix}hostfxr{_sharedLibraryExtension}");
}
Expand Down
Loading